[libvirt] [PATCH v5] ESX: Add routines to interface driver

2012-08-02 Thread Ata E Husain Bohra
Major changes includes:
a. Check for Memory allocation from strdup calls.
b. Removed ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_STRING_LIST workaround
c. Remove overwriting of error messages where it's not required.

Ata E Husain Bohra (1):
  ESX: Add routines to interface driver

 src/esx/esx_interface_driver.c |  551 +++-
 src/esx/esx_vi.c   |  125 +
 src/esx/esx_vi.h   |   10 +
 src/esx/esx_vi_generator.input |  227 +
 src/esx/esx_vi_generator.py|   23 ++
 src/esx/esx_vi_types.c |2 -
 6 files changed, 934 insertions(+), 4 deletions(-)

-- 
1.7.9.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH v5] ESX: Add routines to interface driver

2012-08-02 Thread Ata E Husain Bohra
Add following routines to esx_interface_driver:
esxNumOfInterfaces,
esxNumOfDefinedInterfaces,
esxListInterfaces,
esxListDefinedInterfaces,
esxInterfaceLookupByMACString,
esxInterfaceGetXMLDesc,
esxInterfaceUndefine,
esxInterfaceCreate,
esxInterfaceDestroy

Signed-off-by: Ata E Husain Bohra ata.hus...@hotmail.com
---
 src/esx/esx_interface_driver.c |  551 +++-
 src/esx/esx_vi.c   |  125 +
 src/esx/esx_vi.h   |   10 +
 src/esx/esx_vi_generator.input |  227 +
 src/esx/esx_vi_generator.py|   23 ++
 src/esx/esx_vi_types.c |2 -
 6 files changed, 934 insertions(+), 4 deletions(-)

diff --git a/src/esx/esx_interface_driver.c b/src/esx/esx_interface_driver.c
index 501409a..e9f0d4a 100644
--- a/src/esx/esx_interface_driver.c
+++ b/src/esx/esx_interface_driver.c
@@ -23,6 +23,9 @@
  */
 
 #include config.h
+#include sys/socket.h
+#include netinet/in.h
+#include arpa/inet.h
 
 #include internal.h
 #include util.h
@@ -34,6 +37,7 @@
 #include esx_vi.h
 #include esx_vi_methods.h
 #include esx_util.h
+#include interface_conf.h
 
 #define VIR_FROM_THIS VIR_FROM_ESX
 
@@ -67,10 +71,553 @@ esxInterfaceClose(virConnectPtr conn)
 
 
 
+static int
+esxNumOfInterfaces(virConnectPtr conn)
+{
+bool success = false;
+esxPrivate *priv = conn-interfacePrivateData;
+esxVI_HostVirtualNic *hostVirtualNicList = NULL;
+const esxVI_HostVirtualNic *hostVirtualNic = NULL;
+int count = 0;
+
+if (esxVI_EnsureSession(priv-primary)  0 ||
+esxVI_LookupHostVirtualNicList(priv-primary,
+hostVirtualNicList)  0) {
+goto cleanup;
+}
+
+if (hostVirtualNicList == NULL) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+  _(Could not retrieve HostVirtualNic List));
+
+goto cleanup;
+}
+
+for (hostVirtualNic = hostVirtualNicList;
+ hostVirtualNic != NULL;
+ hostVirtualNic = hostVirtualNic-_next) {
+count++;
+}
+
+success = true;
+
+cleanup:
+
+esxVI_HostVirtualNic_Free(hostVirtualNicList);
+
+return success ? count : -1;
+
+}
+
+
+
+static int
+esxNumOfDefinedInterfaces(virConnectPtr conn ATTRIBUTE_UNUSED)
+{
+// ESX interfaces are always active
+return 0;
+
+}
+
+
+
+static int
+esxListInterfaces(virConnectPtr conn, char **names, int maxnames)
+{
+int result = -1;
+esxPrivate *priv = conn-interfacePrivateData;
+esxVI_HostVirtualNic *hostVirtualNicList = NULL;
+const esxVI_HostVirtualNic *hostVirtualNic = NULL;
+int i = 0;
+
+if (esxVI_EnsureSession(priv-primary)  0 ||
+esxVI_LookupHostVirtualNicList(priv-primary,
+   hostVirtualNicList)  0) {
+goto cleanup;
+}
+
+if (hostVirtualNicList == NULL) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+_(Could not retrieve vNIC List));
+goto cleanup;
+}
+
+for (i= 0, hostVirtualNic = hostVirtualNicList;
+ hostVirtualNic != NULL  i  maxnames;
+ ++i, hostVirtualNic = hostVirtualNic-_next) {
+names[i] = strdup(hostVirtualNic-device);
+
+if (names[i] == NULL) {
+for(;i =0;--i) {
+VIR_FREE(names[i]);
+}
+virReportOOMError();
+goto cleanup;
+}
+}
+
+result = i;
+
+ cleanup:
+
+esxVI_HostVirtualNic_Free(hostVirtualNicList);
+
+return result;
+
+}
+
+
+
+static int
+esxListDefinedInterfaces(virConnectPtr conn ATTRIBUTE_UNUSED,
+ char **names ATTRIBUTE_UNUSED,
+ int maxnames ATTRIBUTE_UNUSED)
+{
+// ESX interfaces are always active
+return 0;
+
+}
+
+
+
+static virInterfacePtr
+esxInterfaceLookupByName(virConnectPtr conn, const char *name)
+{
+virInterfacePtr ret = NULL;
+esxPrivate *priv = conn-interfacePrivateData;
+esxVI_HostVirtualNic *hostVirtualNicList = NULL;
+const esxVI_HostVirtualNic *hostVirtualNic = NULL;
+
+if (esxVI_EnsureSession(priv-primary)  0 ||
+esxVI_LookupHostVirtualNicList(priv-primary,
+   hostVirtualNicList)  0) {
+goto cleanup;
+}
+
+if (hostVirtualNicList == 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+  _(Could not retrieve HostVirtualNic List));
+goto cleanup;
+}
+
+
+for(hostVirtualNic = hostVirtualNicList;
+hostVirtualNic != NULL;
+hostVirtualNic = hostVirtualNic-_next) {
+if (STREQ(hostVirtualNic-device, name)) {
+if (hostVirtualNic-spec == NULL ||
+hostVirtualNic-spec-mac == NULL) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+  _(Malformed HostVirtualNicSpec));
+goto cleanup;
+}
+
+ret = virGetInterface(conn, hostVirtualNic-device,
+

Re: [libvirt] [PATCH 01/49] Fix indentions

2012-08-02 Thread Osier Yang

On 2012年07月21日 00:17, Daniel P. Berrange wrote:

On Fri, Jul 20, 2012 at 10:15:29AM -0600, Eric Blake wrote:

On 07/20/2012 08:24 AM, Osier Yang wrote:

Some of the macros use tab, while the left use spaces, this patch
change it to always use the spaces. And a few aligning fixes.
---
  src/datatypes.h |   86 +++---
  1 files changed, 43 insertions(+), 43 deletions(-)


ACK.



diff --git a/src/datatypes.h b/src/datatypes.h
index fc284d2..01a8544 100644
--- a/src/datatypes.h
+++ b/src/datatypes.h
@@ -33,8 +33,8 @@
   * magic value used to protect the API when pointers to connection structures
   * are passed down by the users.
   */
-# define VIR_CONNECT_MAGIC 0x4F23DEAD
-# define VIR_IS_CONNECT(obj)   ((obj)  (obj)-magic==VIR_CONNECT_MAGIC)
+# define VIR_CONNECT_MAGIC   0x4F23DEAD
+# define VIR_IS_CONNECT(obj) ((obj)  (obj)-magic==VIR_CONNECT_MAGIC)


Conflicts with Dan's series to use virObject.


Push this patch now independantly of the rest of this huge series.
I'll sort out conflicts when I rebase my virObject code next week.



Oh, I misunderstood you had push it, now pushed, sorry if it
causes conflicts.

Regards,
Osier

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] fix error on loading libvirt_driver_qemu.so

2012-08-02 Thread Hu Tao
When start up libvirtd, it gives error like this(wrapped):

2012-08-02 06:59:03.414+: 5463: error :
  virDriverLoadModule:78 : failed to load module
  /usr/lib64/libvirt/connection-driver/libvirt_driver_qemu.so
  /usr/lib64/libvirt/connection-driver/libvirt_driver_qemu.so:
  undefined symbol: virSecurityManagerGetProcessLabel
2012-08-02 06:59:03.415+: 5463: error :
  virDriverLoadModule:78 : failed to load module
  /usr/lib64/libvirt/connection-driver/libvirt_driver_lxc.so
  /usr/lib64/libvirt/connection-driver/libvirt_driver_lxc.so:
  undefined symbol: virSecurityManagerGetProcessLabel

This patch fixes the problem.

---
 src/Makefile.am |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index b48ce65..c8f3e18 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -831,7 +831,8 @@ endif
 if WITH_QEMU
 noinst_LTLIBRARIES += libvirt_driver_qemu_impl.la
 libvirt_driver_qemu_la_SOURCES =
-libvirt_driver_qemu_la_LIBADD = libvirt_driver_qemu_impl.la
+libvirt_driver_qemu_la_LIBADD = libvirt_driver_qemu_impl.la \
+libvirt_driver_security.la
 if WITH_DRIVER_MODULES
 mod_LTLIBRARIES += libvirt_driver_qemu.la
 libvirt_driver_qemu_la_LIBADD += ../gnulib/lib/libgnu.la
-- 
1.7.10.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCHv3 1/3] domain_conf: Add USB controler model none

2012-08-02 Thread Jiri Denemark
On Mon, Jul 23, 2012 at 14:19:13 +0200, Peter Krempa wrote:
 Libvirt adds a USB controller to the guest even if the user does not
 specify any in the XML. This is due to back-compat reasons.
 
 To allow disabling USB for a guest this patch adds a new USB controller
 type none that disables USB support for the guest.
 ---
 Diff to v2:
 - added docs to formatdomain.hmtl
 - changed error reporting functions to global ones
 ---
  docs/formatdomain.html.in |6 +++-
  docs/schemas/domaincommon.rng |1 +
  src/conf/domain_conf.c|   55 
 -
  src/conf/domain_conf.h|1 +
  src/qemu/qemu_command.c   |3 +-
  5 files changed, 62 insertions(+), 4 deletions(-)
 
...
 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
 index c53722a..cf3b1c4 100644
 --- a/src/conf/domain_conf.c
 +++ b/src/conf/domain_conf.c
...
 @@ -9043,6 +9074,14 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr 
 caps,
  if (!hostdev)
  goto error;
 
 +if (hostdev-source.subsys.type == 
 VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB 
 +usb_none) {
 +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
 +   _(Can't add USB device passthrough: 

I think Can't add host USB device would better fit the name of the element.

 + USB is disabled in this host));
 +goto error;
 +}
 +
  def-hostdevs[def-nhostdevs++] = hostdev;
  }
  VIR_FREE(nodes);
...
 @@ -9128,6 +9174,13 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr 
 caps,
  if (!redirdev)
  goto error;
 
 +if (redirdev-bus == VIR_DOMAIN_REDIRDEV_BUS_USB  usb_none) {
 + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
 +_(Can't add USB redir device: 

Can't add redirected USB device seems better to me.

 +  USB is disabled for this domain));
 +goto error;
 +}
 +
  def-redirdevs[def-nredirdevs++] = redirdev;
  }
  VIR_FREE(nodes);
...

ACK

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH V1] on special migration(domain defined, not started yet)

2012-08-02 Thread liguang


From: liguang lig.f...@cn.fujitsu.com

a roughly way for offline-migrate (domain defined,
not started yet), now can do like this:
migrate --hard-migrate --xml dom.xml dom qemu+ssh://target/system

this patch will push dom.xml and all disk images to target

Signed-off-by: liguang lig.f...@cn.fujitsu.com
---
 tools/virsh.c |   76
+
 1 files changed, 76 insertions(+), 0 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 53d1825..5793233 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -7344,9 +7344,75 @@ static const vshCmdOptDef opts_migrate[] = {
 {dname, VSH_OT_DATA, 0, N_(rename to new name during migration
(if supported))},
 {timeout, VSH_OT_INT, 0, N_(force guest to suspend if live
migration exceeds timeout (in seconds))},
 {xml, VSH_OT_STRING, 0, N_(filename containing updated XML for
the target)},
+{hard-migrate, VSH_OT_BOOL, 0, N_(migration when there's no
domain)},
 {NULL, 0, 0, NULL}
 };
 
+#define VIR_MIGRATE_HARD 1  10
+#define push_file(file) {   \
+virAsprintf(topath, %s:%s, to, file);\
+cmd = virCommandNewArgList(scp, file, topath, NULL);  \
+vshPrint(ctl, pushing %s to %s\n, file, to);  \
+if (virCommandRunAsync(cmd, NULL)  0 ||\
+virCommandWait(cmd, NULL)  0) {\
+virshReportError(ctl);  \
+goto cleanup;   \
+}   \
+}
+
+static void
+vshMigrateHard(vshControl *ctl, char *doc, char dst[])
+{
+xmlDocPtr xml = NULL;
+xmlXPathObjectPtr obj= NULL;
+xmlXPathContextPtr ctxt = NULL;
+xmlNodePtr *disks = NULL;
+virCommandPtr cmd;
+int i = 0, ret = 0;
+int outfd = STDOUT_FILENO;
+int errfd = STDERR_FILENO;
+char *src[] = {NULL}, *to, *topath;
+
+if (!vshConnectionUsability(ctl, ctl-conn))
+return;
+
+xml = virXMLParseFileCtxt(doc, ctxt);
+if (!xml) {
+vshError(NULL, %s, _(Fail to get domain information from));
+goto cleanup;
+}
+
+ret = virXPathNodeSet(./devices/disk, ctxt, disks);
+if (ret  0) {
+vshError(NULL, %s, _(Fail to get disk node));
+goto cleanup;
+}
+
+to = strtok(dst, /);
+to = strtok(NULL, /);
+virCommandSetInputFD(cmd, STDIN_FILENO);
+virCommandSetOutputFD(cmd, outfd);
+virCommandSetErrorFD(cmd, errfd);
+
+push_file(doc);
+
+for (i = 0 ; i  ret ; i++) {
+ctxt-node = disks[i];
+src[i] = virXPathString(string(./source/@file
+|./source/@dir
+|./source/@name), ctxt);
+push_file(src[i]);
+}
+
+cleanup:
+xmlXPathFreeObject(obj);
+xmlXPathFreeContext(ctxt);
+xmlFreeDoc(xml);
+virCommandFree(cmd);
+if (src)
+VIR_FREE(src);return;
+}
+
 static void
 doMigrate (void *opaque)
 {
@@ -7413,12 +7479,22 @@ doMigrate (void *opaque)
 if (vshCommandOptBool(cmd, unsafe))
 flags |= VIR_MIGRATE_UNSAFE;
 
+if (vshCommandOptBool(cmd, hard-migrate)) {
+flags |= VIR_MIGRATE_HARD;
+if (xmlfile == NULL)
+vshError(ctl, _(please specify xmlfile for
hard-migrate));
+}
 if (xmlfile 
 virFileReadAll(xmlfile, 8192, xml)  0) {
 vshError(ctl, _(file '%s' doesn't exist), xmlfile);
 goto out;
 }
 
+if (flags  VIR_MIGRATE_HARD) {
+vshMigrateHard(ctl, (char *)xmlfile, (char *)desturi);
+goto out;
+}
+
 if ((flags  VIR_MIGRATE_PEER2PEER) ||
 vshCommandOptBool(cmd, direct)) {
 /* For peer2peer migration or direct migration we only expect
one URI
-- 
1.7.2.5


在 2012-08-01三的 06:13 -0600,Eric Blake写道:
 On 07/31/2012 09:30 PM, liguang wrote:
  Hi, All
  
  If a VM domain defined, but not started yet,
  and I want to migrate it to another server,
  so that It can be started at there, what's 
  should i do? or is it rational?
 
 Yes it is rational, and you're not the first to request it.
 Unfortunately, we haven't yet taught 'virsh migrate' to support offline
 migration, even though (or because?) it is dead simple to cobble
 together yourself:
 
 source$ virsh dumpxml $dom  file.xml
 dest$ virsh define file.xml
 
 optionally followed by
 source$ virsh undefine $dom
 
 Patches are welcome to make 'virsh migrate' automatically handle an
 offline migration.
 



--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCHv3 2/3] domain_conf: Add helpers to verify if device configuration is valid

2012-08-02 Thread Jiri Denemark
On Mon, Jul 23, 2012 at 14:19:14 +0200, Peter Krempa wrote:
 This patch adds helpers that validate domain's device configuration.
 This will be needed later on to verify devices being hot-plugged to
 guests. If the guest has no USB bus, then it's not valid to plug a USB
 device to that guest.
 ---
 Diff to v2:
 - split out USB device checking to a separate function
 - made virDomainDefHasUSB static as it's not used outside of domain_conf.c
 ---
  src/conf/domain_conf.c   |   52 
 ++
  src/conf/domain_conf.h   |3 ++
  src/libvirt_private.syms |1 +
  3 files changed, 56 insertions(+), 0 deletions(-)

ACK

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] fix error on loading libvirt_driver_qemu.so

2012-08-02 Thread Jiri Denemark
On Thu, Aug 02, 2012 at 15:28:44 +0800, Hu Tao wrote:
 When start up libvirtd, it gives error like this(wrapped):
 
 2012-08-02 06:59:03.414+: 5463: error :
   virDriverLoadModule:78 : failed to load module
   /usr/lib64/libvirt/connection-driver/libvirt_driver_qemu.so
   /usr/lib64/libvirt/connection-driver/libvirt_driver_qemu.so:
   undefined symbol: virSecurityManagerGetProcessLabel
 2012-08-02 06:59:03.415+: 5463: error :
   virDriverLoadModule:78 : failed to load module
   /usr/lib64/libvirt/connection-driver/libvirt_driver_lxc.so
   /usr/lib64/libvirt/connection-driver/libvirt_driver_lxc.so:
   undefined symbol: virSecurityManagerGetProcessLabel
 
 This patch fixes the problem.
 
 ---
  src/Makefile.am |3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/src/Makefile.am b/src/Makefile.am
 index b48ce65..c8f3e18 100644
 --- a/src/Makefile.am
 +++ b/src/Makefile.am
 @@ -831,7 +831,8 @@ endif
  if WITH_QEMU
  noinst_LTLIBRARIES += libvirt_driver_qemu_impl.la
  libvirt_driver_qemu_la_SOURCES =
 -libvirt_driver_qemu_la_LIBADD = libvirt_driver_qemu_impl.la
 +libvirt_driver_qemu_la_LIBADD = libvirt_driver_qemu_impl.la \
 +libvirt_driver_security.la
  if WITH_DRIVER_MODULES
  mod_LTLIBRARIES += libvirt_driver_qemu.la
  libvirt_driver_qemu_la_LIBADD += ../gnulib/lib/libgnu.la

NACK, the security driver needs to linked directly into libvirtd. I tried to
fix this with my recent patch but it only worked when libvirt is built
without driver modules. I'll prepare a new patch to really fix this issue.

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCHv3 3/3] qemu: Add support for none USB controller

2012-08-02 Thread Jiri Denemark
On Mon, Jul 23, 2012 at 14:19:15 +0200, Peter Krempa wrote:
 This patch enables the none USB controller for qemu guests and adds
 valdiation on hot-plugged devices if the guest has USB disabled.
 
 This patch also adds a set of tests to check parsing of domain XMLs that
 use the none controller and some forbidden situations concerning it.
 ---
 Diff to v2:
 - tests squashed in directly
 ---
  src/qemu/qemu_command.c|7 ++
  src/qemu/qemu_driver.c |6 +
  .../qemuxml2argvdata/qemuxml2argv-usb-none-hub.xml |   19 ++
  .../qemuxml2argv-usb-none-other.xml|   19 ++
  .../qemuxml2argv-usb-none-usbtablet.xml|   21 
 
  tests/qemuxml2argvdata/qemuxml2argv-usb-none.args  |5 
  tests/qemuxml2argvdata/qemuxml2argv-usb-none.xml   |   16 +++
  tests/qemuxml2argvtest.c   |   10 +
  8 files changed, 103 insertions(+), 0 deletions(-)
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-none-hub.xml
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-none-other.xml
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-none-usbtablet.xml
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-none.args
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-none.xml

ACK

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 01/49] Fix indentions

2012-08-02 Thread Daniel P. Berrange
On Thu, Aug 02, 2012 at 03:19:29PM +0800, Osier Yang wrote:
 On 2012年07月21日 00:17, Daniel P. Berrange wrote:
 On Fri, Jul 20, 2012 at 10:15:29AM -0600, Eric Blake wrote:
 On 07/20/2012 08:24 AM, Osier Yang wrote:
 Some of the macros use tab, while the left use spaces, this patch
 change it to always use the spaces. And a few aligning fixes.
 ---
   src/datatypes.h |   86 
  +++---
   1 files changed, 43 insertions(+), 43 deletions(-)
 
 ACK.
 
 
 diff --git a/src/datatypes.h b/src/datatypes.h
 index fc284d2..01a8544 100644
 --- a/src/datatypes.h
 +++ b/src/datatypes.h
 @@ -33,8 +33,8 @@
* magic value used to protect the API when pointers to connection 
  structures
* are passed down by the users.
*/
 -# define VIR_CONNECT_MAGIC0x4F23DEAD
 -# define VIR_IS_CONNECT(obj)  ((obj)  
 (obj)-magic==VIR_CONNECT_MAGIC)
 +# define VIR_CONNECT_MAGIC   0x4F23DEAD
 +# define VIR_IS_CONNECT(obj) ((obj)  (obj)-magic==VIR_CONNECT_MAGIC)
 
 Conflicts with Dan's series to use virObject.
 
 Push this patch now independantly of the rest of this huge series.
 I'll sort out conflicts when I rebase my virObject code next week.
 
 
 Oh, I misunderstood you had push it, now pushed, sorry if it
 causes conflicts.

Don't worry, its not a problem.


Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCHv2] build: add stubs so mdns code can be unconditionally compiled

2012-08-02 Thread Daniel P. Berrange
On Wed, Aug 01, 2012 at 05:52:42PM -0600, Eric Blake wrote:
 The recent changes to test exported symbols flushed out the fact
 that we were unconditionally linking against symbols that were
 only conditionally compiled under HAVE_AVAHI.
 
 * src/Makefile.am (libvirt_net_rpc_server_la_SOURCES): Compile
 virnetservermdns unconditionally.
 * configure.ac (HAVE_AVAHI): Drop unused automake conditional.
 * src/rpc/virnetservermdns.c: Add fallbacks when Avahi is not
 present.
 
 ---
 
 Definitely more involved than splitting out a separate .syms file, so
 I'm not sure whether this approach is better than the v1 approach.
 But I did promise to propose this alternative, so here it is.  I tested
 both with and without avahi development libraries present.
 
  configure.ac   |  1 -
  src/Makefile.am|  8 +---
  src/rpc/virnetservermdns.c | 98 
 ++
  3 files changed, 91 insertions(+), 16 deletions(-)

Hmm, there should be a change to src/rpc/virnetserver.c to
remove the avahi conditionals there I think.  If everything
still operates when avahi is disabled, then I think I prefer
this patch, even though it is more complex, because it means
the HAVE_AVAHI conditionals don't spread across the source
tree to every user of this API.

ACK

 diff --git a/configure.ac b/configure.ac
 index 400ac3b..e93bbb5 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -1248,7 +1248,6 @@ if test x$with_avahi = xyes || test x$with_avahi 
 = xcheck; then
[whether Avahi is used to broadcast server presense])
fi
  fi
 -AM_CONDITIONAL([HAVE_AVAHI], [test x$with_avahi = xyes])
  AC_SUBST([AVAHI_CFLAGS])
  AC_SUBST([AVAHI_LIBS])
 
 diff --git a/src/Makefile.am b/src/Makefile.am
 index b48ce65..8fbbabd 100644
 --- a/src/Makefile.am
 +++ b/src/Makefile.am
 @@ -1529,14 +1529,8 @@ libvirt_net_rpc_server_la_SOURCES = \
   rpc/virnetserverprogram.h rpc/virnetserverprogram.c \
   rpc/virnetserverservice.h rpc/virnetserverservice.c \
   rpc/virnetserverclient.h rpc/virnetserverclient.c \
 + rpc/virnetservermdns.h rpc/virnetservermdns.c \
   rpc/virnetserver.h rpc/virnetserver.c
 -if HAVE_AVAHI
 -libvirt_net_rpc_server_la_SOURCES += \
 - rpc/virnetservermdns.h rpc/virnetservermdns.c
 -else
 -EXTRA_DIST += \
 - rpc/virnetservermdns.h rpc/virnetservermdns.c
 -endif
  libvirt_net_rpc_server_la_CFLAGS = \
   $(AVAHI_CFLAGS) \
   $(XDR_CFLAGS) \
 diff --git a/src/rpc/virnetservermdns.c b/src/rpc/virnetservermdns.c
 index 274be19..7c43c40 100644
 --- a/src/rpc/virnetservermdns.c
 +++ b/src/rpc/virnetservermdns.c
 @@ -1,7 +1,7 @@
  /*
   * virnetservermdns.c: advertise server sockets
   *
 - * Copyright (C) 2011 Red Hat, Inc.
 + * Copyright (C) 2011-2012 Red Hat, Inc.
   * Copyright (C) 2007 Daniel P. Berrange
   *
   * Derived from Avahi example service provider code.
 @@ -29,14 +29,16 @@
  #include stdio.h
  #include stdlib.h
 
 -#include avahi-client/client.h
 -#include avahi-client/publish.h
 +#if HAVE_AVAHI
 +# include avahi-client/client.h
 +# include avahi-client/publish.h
 
 -#include avahi-common/alternative.h
 -#include avahi-common/simple-watch.h
 -#include avahi-common/malloc.h
 -#include avahi-common/error.h
 -#include avahi-common/timeval.h
 +# include avahi-common/alternative.h
 +# include avahi-common/simple-watch.h
 +# include avahi-common/malloc.h
 +# include avahi-common/error.h
 +# include avahi-common/timeval.h
 +#endif
 
  #include virnetservermdns.h
  #include event.h
 @@ -55,18 +57,23 @@ struct _virNetServerMDNSEntry {
 
  struct _virNetServerMDNSGroup {
  virNetServerMDNSPtr mdns;
 +#if HAVE_AVAHI
  AvahiEntryGroup *handle;
 +#endif
  char *name;
  virNetServerMDNSEntryPtr entry;
  virNetServerMDNSGroupPtr next;
  };
 
  struct _virNetServerMDNS {
 +#if HAVE_AVAHI
  AvahiClient *client;
  AvahiPoll *poller;
 +#endif
  virNetServerMDNSGroupPtr group;
  };
 
 +#if HAVE_AVAHI
  /* Avahi API requires this struct name in the app :-( */
  struct AvahiWatch {
  int watch;
 @@ -612,3 +619,78 @@ void virNetServerMDNSEntryFree(virNetServerMDNSEntryPtr 
 entry)
  VIR_FREE(entry-type);
  VIR_FREE(entry);
  }
 +
 +#else /* ! HAVE_AVAHI */
 +
 +static const char *unsupported = N_(avahi not available at build time);
 +
 +virNetServerMDNS *
 +virNetServerMDNSNew(void)
 +{
 +VIR_DEBUG(%s, _(unsupported));
 +return NULL;
 +}
 +
 +int
 +virNetServerMDNSStart(virNetServerMDNS *mdns ATTRIBUTE_UNUSED)
 +{
 +VIR_DEBUG(%s, _(unsupported));
 +return -1;
 +}
 +
 +virNetServerMDNSGroupPtr
 +virNetServerMDNSAddGroup(virNetServerMDNS *mdns ATTRIBUTE_UNUSED,
 + const char *name ATTRIBUTE_UNUSED)
 +{
 +VIR_DEBUG(%s, _(unsupported));
 +return NULL;
 +}
 +
 +void
 +virNetServerMDNSRemoveGroup(virNetServerMDNSPtr mdns ATTRIBUTE_UNUSED,
 +virNetServerMDNSGroupPtr group ATTRIBUTE_UNUSED)
 +{
 +

Re: [libvirt] Next release schedule and a snapshot

2012-08-02 Thread Daniel P. Berrange
On Wed, Aug 01, 2012 at 05:43:22PM +0800, Daniel Veillard wrote:
   Hello everybody,
 
  as suggested when we rolled out 0.9.13, I'm planning to make the
 next release at the end of August. Since we added a driver we should
 probably bump the medium number and shoot for 0.10.0. Also 2 months
 without some official tarball to test was quite long so I made a
 snapshot called 0.9.10-rc0, it's not a release candidate, just a
 snapshot, development goes as usual. I tagged it into the git too
 and it's available at
ftp://libvirt.org/libvirt/
   So there is 3 more weeks of development before entering the 0.10.0
 freeze,

We need to fix  libvirt_public.syms to refer to 0.10.0 instead of
0.9.14. Likewise in some of the source files  docs we need to
remove 0.9.14


Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 06/13] Turn virDomainObjPtr into a virObjectPtr

2012-08-02 Thread Daniel P. Berrange
On Wed, Aug 01, 2012 at 04:39:24PM +0800, Hu Tao wrote:
   void
   virBlkioDeviceWeightArrayClear(virBlkioDeviceWeightPtr deviceWeights,
  int ndevices)
  @@ -723,7 +738,7 @@ virDomainObjListDataFree(void *payload, const void 
  *name ATTRIBUTE_UNUSED)
   {
   virDomainObjPtr obj = payload;
   virDomainObjLock(obj);
  -if (virDomainObjUnref(obj)  0)
  +if (!virObjectUnref(obj))
   virDomainObjUnlock(obj);
   }
 
 I suppose you mean
 
if (virObjectUnref(obj))
 
 here.
 
 But, I can't see any reason to lock then unref then unlock, just unref
 is enough.

I didn't want to change multiple things at the same time. Simplification
of locking in various places can follow later.


Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCHv3 1/3] domain_conf: Add USB controler model none

2012-08-02 Thread Peter Krempa

On 08/02/12 11:00, Jiri Denemark wrote:

On Mon, Jul 23, 2012 at 14:19:13 +0200, Peter Krempa wrote:

Libvirt adds a USB controller to the guest even if the user does not
specify any in the XML. This is due to back-compat reasons.

To allow disabling USB for a guest this patch adds a new USB controller
type none that disables USB support for the guest.
---
Diff to v2:
- added docs to formatdomain.hmtl
- changed error reporting functions to global ones
---
  docs/formatdomain.html.in |6 +++-
  docs/schemas/domaincommon.rng |1 +
  src/conf/domain_conf.c|   55 -
  src/conf/domain_conf.h|1 +
  src/qemu/qemu_command.c   |3 +-
  5 files changed, 62 insertions(+), 4 deletions(-)


...

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c53722a..cf3b1c4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c

...

@@ -9043,6 +9074,14 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr 
caps,
  if (!hostdev)
  goto error;

+if (hostdev-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB 

+usb_none) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(Can't add USB device passthrough: 


I think Can't add host USB device would better fit the name of the element.


Yep, those are indeed better than my try.




+ USB is disabled in this host));
+goto error;
+}
+
  def-hostdevs[def-nhostdevs++] = hostdev;
  }
  VIR_FREE(nodes);

...

@@ -9128,6 +9174,13 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr 
caps,
  if (!redirdev)
  goto error;

+if (redirdev-bus == VIR_DOMAIN_REDIRDEV_BUS_USB  usb_none) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+_(Can't add USB redir device: 


Can't add redirected USB device seems better to me.


+  USB is disabled for this domain));
+goto error;
+}
+
  def-redirdevs[def-nredirdevs++] = redirdev;
  }
  VIR_FREE(nodes);

...

ACK

Jirka



I changed the error messages to those you suggested and changed the 
version statement docs/formatdomain.html.in to 0.10.0 and pushed with 
the rest of the series. Thanks for the review!


Peter

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] Next release schedule and a snapshot

2012-08-02 Thread Daniel Veillard
On Thu, Aug 02, 2012 at 11:17:33AM +0100, Daniel P. Berrange wrote:
 On Wed, Aug 01, 2012 at 05:43:22PM +0800, Daniel Veillard wrote:
Hello everybody,
  
   as suggested when we rolled out 0.9.13, I'm planning to make the
  next release at the end of August. Since we added a driver we should
  probably bump the medium number and shoot for 0.10.0. Also 2 months
  without some official tarball to test was quite long so I made a
  snapshot called 0.9.10-rc0, it's not a release candidate, just a
  snapshot, development goes as usual. I tagged it into the git too
  and it's available at
 ftp://libvirt.org/libvirt/
So there is 3 more weeks of development before entering the 0.10.0
  freeze,
 
 We need to fix  libvirt_public.syms to refer to 0.10.0 instead of
 0.9.14. Likewise in some of the source files  docs we need to
 remove 0.9.14

  Yup I just discovered that :-\ ... The resulting binaries still work
but it's really only a work in progress !

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [test-API][PATCH] Fix xml parser problem when node have both attribute and value

2012-08-02 Thread Wayne Sun
  When xml node have both attribute and value at first level, the parser
  will broke. After fix, the node key will have a dictionary with both
  value and attr inside. For example, the xml node:
  capacity unit='bytes'536870912000/capacity
  will be parsed into:
  {u'capacity': {'attr': {u'unit': u'bytes'}, 'value': u'536870912000'}}

  Also when fetch the attribute key, should use a new param (attrkey)
  other than exist key in outside loop.

Signed-off-by: Wayne Sun g...@redhat.com
---
 utils/xml_parser.py |   22 +-
 1 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/utils/xml_parser.py b/utils/xml_parser.py
index 04e7501..01b928f 100644
--- a/utils/xml_parser.py
+++ b/utils/xml_parser.py
@@ -88,15 +88,21 @@ class xml_parser(object):
 if thenode.attributes != None:
 tmpattr = dict()
 if thenode.attributes.length  0:
-for key in thenode.attributes.keys():
+for attrkey in thenode.attributes.keys():
 tmpattr.update(
-{key:thenode.attributes.get(key).nodeValue})
+
{attrkey:thenode.attributes.get(attrkey).nodeValue})
 attrdic = { attr:tmpattr }
 if key in out:
 if out[key] == None:
-out[key] = value
 if attrdic != None:
-out[key].update(attrdic)
+if value == None:
+out[key] = attrdic
+else:
+valdic = { value:value }
+valdic.update(attrdic)
+out[key] = valdic
+else:
+out[key] = value
 elif type(out[key]) == list:
 if attrdic != None:
 newdict.update(attrdic)
@@ -111,7 +117,13 @@ class xml_parser(object):
 else:
 out[key] = value
 if attrdic != None:
-out[key].update(attrdic)
+if value == None:
+newdict[key] = attrdic
+else:
+valdic = { value:value }
+valdic.update(attrdic)
+newdict = valdic
+out[key] = newdict
 self.parseintodict(thenode, level+1, out, key)
 return out
 
-- 
1.7.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Remove reference to the ex future release 0.9.14

2012-08-02 Thread Daniel Veillard
On Thu, Aug 02, 2012 at 11:17:33AM +0100, Daniel P. Berrange wrote:
 We need to fix  libvirt_public.syms to refer to 0.10.0 instead of
 0.9.14. Likewise in some of the source files  docs we need to
 remove 0.9.14

And replace it to the expected 0.10.0

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index c834577..f97c630 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -780,7 +780,7 @@
 CPU model will fail. Supported values for codefallback/code
 attribute are: codeallow/code (this is the default), and
 codeforbid/code. The optional codevendor_id/code attribute
-(span class=sinceSince 0.9.14/span)  can be used to set the
+(span class=sinceSince 0.10.0/span)  can be used to set the
 vendor id seen by the guest. It must be exactly 12 characters long.
 If not set the vendor id of the host is used. Typical possible
 values are AuthenticAMD and GenuineIntel./dd
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 5004182..e3ba119 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -544,7 +544,7 @@ LIBVIRT_0.9.13 {
 virDomainSnapshotRef;
 } LIBVIRT_0.9.11;
 
-LIBVIRT_0.9.14 {
+LIBVIRT_0.10.0 {
 global:
 virDomainGetHostname;
 virConnectRegisterCloseCallback;
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 4cc7f46..48b5219 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -2170,7 +2170,7 @@ static virDriver openvzDriver = {
 .domainIsUpdated = openvzDomainIsUpdated, /* 0.8.6 */
 .isAlive = openvzIsAlive, /* 0.9.8 */
 .domainUpdateDeviceFlags = openvzDomainUpdateDeviceFlags, /* 0.9.13 */
-.domainGetHostname = openvzDomainGetHostname, /* 0.9.14 */
+.domainGetHostname = openvzDomainGetHostname, /* 0.10.0 */
 };
 
 int openvzRegister(void) {
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 9354cb4..b9e2127 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5366,7 +5366,7 @@ static virDriver remote_driver = {
 .domainGetDiskErrors = remoteDomainGetDiskErrors, /* 0.9.10 */
 .domainSetMetadata = remoteDomainSetMetadata, /* 0.9.10 */
 .domainGetMetadata = remoteDomainGetMetadata, /* 0.9.10 */
-.domainGetHostname = remoteDomainGetHostname, /* 0.9.14 */
+.domainGetHostname = remoteDomainGetHostname, /* 0.10.0 */
 };
 
 static virNetworkDriver network_driver = {


-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 06/13] Turn virDomainObjPtr into a virObjectPtr

2012-08-02 Thread Daniel P. Berrange
On Thu, Aug 02, 2012 at 11:13:20AM +0100, Daniel P. Berrange wrote:
 On Wed, Aug 01, 2012 at 04:39:24PM +0800, Hu Tao wrote:
void
virBlkioDeviceWeightArrayClear(virBlkioDeviceWeightPtr deviceWeights,
   int ndevices)
   @@ -723,7 +738,7 @@ virDomainObjListDataFree(void *payload, const void 
   *name ATTRIBUTE_UNUSED)
{
virDomainObjPtr obj = payload;
virDomainObjLock(obj);
   -if (virDomainObjUnref(obj)  0)
   +if (!virObjectUnref(obj))
virDomainObjUnlock(obj);
}
  
  I suppose you mean
  
 if (virObjectUnref(obj))
  
  here.

Oh, yes I do.

  But, I can't see any reason to lock then unref then unlock, just unref
  is enough.
 
 I didn't want to change multiple things at the same time. Simplification
 of locking in various places can follow later.
 

Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 02/13] Rewrite virAtomic APIs using GLib's atomic ops code

2012-08-02 Thread Daniel P. Berrange
On Tue, Jul 31, 2012 at 06:09:13PM -0600, Eric Blake wrote:
 On 07/31/2012 10:58 AM, Daniel P. Berrange wrote:
  From: Daniel P. Berrange berra...@redhat.com
  
  There are a few issues with the current virAtomic APIs
  
   - They require use of a virAtomicInt struct instead of a plain
 int type
   - Several of the methods do not implement memory barriers
   - The methods do not implement compiler re-ordering barriers
   - There is no Win32 native impl
  
  The GLib library has a nice LGPLv2+ licensed impl of atomic
  ops that works with GCC, Win32, or pthreads.h that addresses
  all these problems. The main downside to their code is that
  the pthreads impl uses a single global mutex, instead of
  a per-variable mutex. Given that it does have a Win32 impl
  though, we don't expect anyone to seriously use the pthread.h
  impl, so this downside is not significant.
  
  * .gitignore: Ignore test case
  * configure.ac: Check for which atomic ops impl to use
  * src/Makefile.am: Add viratomic.c
  * src/nwfilter/nwfilter_dhcpsnoop.c: Switch to new atomic
ops APIs and plain int datatype
  * src/util/viratomic.h: inline impls of all atomic ops
for GCC, Win32 and pthreads
  * src/util/viratomic.c: Global pthreads mutex for atomic
ops
  * tests/viratomictest.c: Test validate to validate safety
of atomic ops.
  
  Signed-off-by: Daniel P. Berrange berra...@redhat.com
  ---
 
  +dnl Note that the atomic ops are only available with GCC on x86 when
  +dnl using -march=i486 or higher.  If we detect that the atomic ops are
  +dnl not available but would be available given the right flags, we want
  +dnl to abort and advise the user to fix their CFLAGS.  It's better to do
  +dnl that then to silently fall back on emulated atomic ops just because
  +dnl the user had the wrong build environment.
  +
  +atomic_ops=
  +
  +AC_MSG_CHECKING([for atomic ops implementation])
  +
  +AC_TRY_COMPILE([], [__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4;],[
 
 The autoconf manual prefers 'AC_COMPILE_IFELSE' over 'AC_TRY_COMPILE',
 but as you are copying code, I won't worry if you don't change it.
 
  +  atomic_ops=gcc
  +],[])
  +
  +if test $atomic_ops =  ; then
  +  SAVE_CFLAGS=${CFLAGS}
  +  CFLAGS=-march=i486
 
 Should this be:
 
 CFLAGS=$CFLAGS -march=i486
 
 so as not to lose previous flags that might be important?

I don't think it really matters in the context of this test

  +  AC_TRY_COMPILE([],
  + [__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4;],
  + [AC_MSG_ERROR([Libvirt must be build with -march=i486 or 
  later.])],
 
 s/build/built/
 
 Okay - the intent here is that if we compiled and
 __GCC_HAVE_SYNC_COMPARE_AND_SWAP failed, then we add a new option, and
 the recompilation attempt succeeds, then we a) must be using gcc, b) gcc
 recognizes the option, so we must be x86 (all other scenarios either
 passed on the first compilation, or point to a different architecture
 and/or different compiler so both compile attempts failed).  Since the
 test is so simple, discarding all existing CFLAGS to look for just
 -march=i486 probably does the job, and I guess my earlier comment is not
 strictly necessary.
 
 Do we need to worry about updating './autogen.sh' to add this CFLAGS
 value automatically, or is gcc typically spec'd to a new enough platform
 by default in x86 distros these days?  Then again, I just tested the
 patch myself and didn't hit the warning, so at least Fedora 17 has gcc
 spec'd to implicitly assume that flag.

I believe all common distros have GCC builds default to at least i486
these days, precisely to get atomic op support. So don't reckon we
need todo anything here.

 
  @@ -1301,6 +1301,10 @@ if HAVE_SASL
   USED_SYM_FILES += libvirt_sasl.syms
   endif
   
  +if WITH_ATOMIC_OPS_PTHREAD
  +USED_SYM_FILES += libvirt_atomic.syms
  +endif
  +
   EXTRA_DIST += \
 libvirt_public.syms  \
 libvirt_private.syms \
 
 Incomplete.  EXTRA_DIST also needs to list libvirt_atomic.syms.

Opps, yes, will add.


  diff --git a/src/util/viratomic.c b/src/util/viratomic.c
  new file mode 100644
  index 000..af846ff
  --- /dev/null
  +++ b/src/util/viratomic.c
  @@ -0,0 +1,35 @@
  +/*
 
  +
  +#ifdef VIR_ATOMIC_OPS_PTHREAD
  +
  +pthread_mutex_t virAtomicLock = PTHREAD_MUTEX_INITIALIZER;
 
 I guess since we know we are using pthread, we can directly use
 pthread_mutex_t instead of our virThread wrappers in our thread.h.

The main reason is to be able to get the static initializer,
which we don't support, since there's no easy way to achieve
it on Win32. (Mingw pthreads does some horrible hacks to
try, which I didn't fancy doing)

  +++ b/src/util/viratomic.h
  @@ -1,10 +1,11 @@
   /*
* viratomic.h: atomic integer operations
*
  - * Copyright (C) 2012 IBM Corporation
  + * Copyright (C) 2012 Red Hat, Inc.
 
 Normally, I question tossing out an old copyright.  But this is such a
 massive rewrite that I think you're safe.  By the way, the diff was
 horrible 

Re: [libvirt] Generating our docs/search.php with xsltproc

2012-08-02 Thread Daniel Veillard
On Wed, Aug 01, 2012 at 06:19:46PM +0200, Martin Kletzander wrote:
 Hi everyone.

  Re,

 TL;DR is there a way to keep PHP code untouched in XSL transformed XML?

  I guess that you need a dose of disable-output-escaping
  http://www.w3.org/TR/xslt#disable-output-escaping
so basically you import the PHP in text node untouched one way or
anover (double escape of input or XInclude of text part [1])
and then output those fragments with
  xsl:text disable-output-escaping=yes
your PHP code ...
  /xsl:text

 For a while now, I'm trying to make our 'search.php' file generated like
 all the '*.html' files (with all the fancy stuff like up-to-date menu,
 headers and so on).
 
 The problem I've been facing looks like an easy and doable thing /at
 first/, but every normal approach I tried didn't work. I'm most probably
 doing something wrong. I haven't used XSLT that much and this is very
 badly google-able topic as lots of people are using XSL transformation
 *inside* PHP and mangling the search results in their benefit.
 I tried:
  - using CDATA
  - transforming the code with various elements
  - turning off output escaping
  - putting the code into another element
  - various combinations of previous things
  - and few others

  Nice try, you looked in nearly all directions ;-)

 Now it looks like the only option is to put the code part into another
 file and inject it after the transformation, which is ugly, because it
 means lots of modification (and unnecessary lines of code) for one file
 (even though it would be applicable for all /possible/ future scripts).
 
 I know this is not the best place to ask this question, but since we
 have the web page generator using XSLT *and* it is for libvirt's
 benefit, someone on the list might help me.

  One solution might be to XInclude [1] as text the php in the XML data,
and use HTML serialization of the XSLT output [2], but that still looks
error prone.
  To be honnest i would not bother too much about making the output
  generated by XSLT directly, concatenation at the shell/python/perl
would be just as good IMHO as long as we don't need to fix it too often :-)

Daniel

[1] http://www.w3.org/TR/xinclude/
[2] http://www.w3.org/TR/xslt#output

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] Remove reference to the ex future release 0.9.14

2012-08-02 Thread Daniel P. Berrange
On Thu, Aug 02, 2012 at 06:33:14PM +0800, Daniel Veillard wrote:
 On Thu, Aug 02, 2012 at 11:17:33AM +0100, Daniel P. Berrange wrote:
  We need to fix  libvirt_public.syms to refer to 0.10.0 instead of
  0.9.14. Likewise in some of the source files  docs we need to
  remove 0.9.14
 
 And replace it to the expected 0.10.0
 
 diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
 index c834577..f97c630 100644
 --- a/docs/formatdomain.html.in
 +++ b/docs/formatdomain.html.in
 @@ -780,7 +780,7 @@
  CPU model will fail. Supported values for codefallback/code
  attribute are: codeallow/code (this is the default), and
  codeforbid/code. The optional codevendor_id/code attribute
 -(span class=sinceSince 0.9.14/span)  can be used to set the
 +(span class=sinceSince 0.10.0/span)  can be used to set the
  vendor id seen by the guest. It must be exactly 12 characters long.
  If not set the vendor id of the host is used. Typical possible
  values are AuthenticAMD and GenuineIntel./dd
 diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
 index 5004182..e3ba119 100644
 --- a/src/libvirt_public.syms
 +++ b/src/libvirt_public.syms
 @@ -544,7 +544,7 @@ LIBVIRT_0.9.13 {
  virDomainSnapshotRef;
  } LIBVIRT_0.9.11;
  
 -LIBVIRT_0.9.14 {
 +LIBVIRT_0.10.0 {
  global:
  virDomainGetHostname;
  virConnectRegisterCloseCallback;
 diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
 index 4cc7f46..48b5219 100644
 --- a/src/openvz/openvz_driver.c
 +++ b/src/openvz/openvz_driver.c
 @@ -2170,7 +2170,7 @@ static virDriver openvzDriver = {
  .domainIsUpdated = openvzDomainIsUpdated, /* 0.8.6 */
  .isAlive = openvzIsAlive, /* 0.9.8 */
  .domainUpdateDeviceFlags = openvzDomainUpdateDeviceFlags, /* 0.9.13 */
 -.domainGetHostname = openvzDomainGetHostname, /* 0.9.14 */
 +.domainGetHostname = openvzDomainGetHostname, /* 0.10.0 */
  };
  
  int openvzRegister(void) {
 diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
 index 9354cb4..b9e2127 100644
 --- a/src/remote/remote_driver.c
 +++ b/src/remote/remote_driver.c
 @@ -5366,7 +5366,7 @@ static virDriver remote_driver = {
  .domainGetDiskErrors = remoteDomainGetDiskErrors, /* 0.9.10 */
  .domainSetMetadata = remoteDomainSetMetadata, /* 0.9.10 */
  .domainGetMetadata = remoteDomainGetMetadata, /* 0.9.10 */
 -.domainGetHostname = remoteDomainGetHostname, /* 0.9.14 */
 +.domainGetHostname = remoteDomainGetHostname, /* 0.10.0 */
  };
  
  static virNetworkDriver network_driver = {

ACK identical to Eric's patch, but since his isn't pushed and he's
not online yet, go ahead with yours


Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] build: commit to 0.10.0 release naming

2012-08-02 Thread Daniel Veillard
On Wed, Aug 01, 2012 at 01:27:09PM -0600, Eric Blake wrote:
 On 08/01/2012 01:18 PM, Guido Günther wrote:
  On Wed, Aug 01, 2012 at 11:00:35AM -0600, Eric Blake wrote:
  With 0.10.0-rc0 out the door, we are committed to the next version
  number.
 
  * src/libvirt_public.syms (LIBVIRT_0.9.14): Rename...
  (LIBVIRT_0.10.0): ...to this.
  * docs/formatdomain.html.in: Fix fallout.
  * src/openvz/openvz_driver.c (openvzDriver): Likewise.
  * src/remote/remote_driver.c (remote_driver): Likewise.
  ---
 
  I almost pushed this under the trivial rule, but realized that
  anyone that builds an app against rc0 will be binary incompatible
  with the .so post-patch.  Are we okay declaring that rc0 is
  unsupported so the ABI break is okay, or do I need to respin
  the .syms portion of this patch to keep the LIBVIRT_0.9.14
  label even though we had no 0.9.14 release?
  
  If rc1 won't be too far in the future (so it can be pushed into distros)
  just changing the symbol names is probably good enough.
 
 DV said that rc1 might be as much as 3 weeks away.  If distros want to
 push rc0 out the door, and we decide to go with this patch as-is, then
 distros should backport this patch on top of rc0 for minimal pain.

  yeah rc0 is not a release candidate, it's a snapshot, it's basically
unsupported. It may not have compliled (it didn't in some configurations)
it is a completely arbitrary upstream commit, like one of the
   ftp://libvirt.org/libvirt/libvirt-git-snapshot.tar.gz

So your patch looks fine to me, i re-did it on my own too, so ACK

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v2][TCK 1/2] Extend image and memory size for installing guest

2012-08-02 Thread Guannan Ren

On 08/01/2012 06:01 PM, Kyla Zhang wrote:

In fedora 17 with less than 512M memory will cause installation hang,
also the previous image size is too small, so improve them.
---
  lib/Sys/Virt/TCK/NetworkHelpers.pm |6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/Sys/Virt/TCK/NetworkHelpers.pm 
b/lib/Sys/Virt/TCK/NetworkHelpers.pm
index 6ff9eaa..f7f6d70 100644
--- a/lib/Sys/Virt/TCK/NetworkHelpers.pm
+++ b/lib/Sys/Virt/TCK/NetworkHelpers.pm
@@ -66,7 +66,7 @@ sub build_domain{
  
  # We want a bigger disk than normal

  $guest-rmdisk();
-my $diskpath = $tck-create_sparse_disk(nwfilter, main.img, 2048);
+my $diskpath = $tck-create_sparse_disk(nwfilter, main.img, 5120);
  $guest-disk(src = $diskpath,
 dst = vda,
 type= file);
@@ -107,8 +107,8 @@ sub build_domain{
  }
  
  # common configuration

-$guest-maxmem(524288);
-$guest-memory(524288);
+$guest-maxmem(1048576);
+$guest-memory(1048576);
  $guest-graphics(type = vnc,
 port = -1,
 autoport = yes,



   Install in a VM with 512MB RAM freezes forever at Trying to 
unpack rootfs image as initramfs

   We encounter this problem on fedora17.
   The same problem happened before:
   https://bugzilla.redhat.com/show_bug.cgi?id=707481
   Most of testing machine should have more than 1 GB memory, so 
change the code.
   Kyla, you'd better give more infomation in git commite log next 
time, describe your problem and

   why we need to change it.

   ACK.

   Guannan Ren




--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] namespace clean shared libraries

2012-08-02 Thread Wido den Hollander

On 07/08/2012 07:51 PM, Bruno Haible wrote:

Daniel P. Berrange wrote:

If its better to just do it in libvirt config.h, then we
can do that too


Yes, doing '#define foo libvirt_foo' in config.h is the preferred way
of achieving a namespace clean shared library.

There are two ways to generate these #defines:

1) You collect manually, on various systems, the set of symbols that you
don't want to clash with symbols from other shared libraries. You need
to do this on various systems, because gnulib may define functions
'rpl_fflush' or 'dprintf' on some systems and not on others.

2) You collect, from a set of header files, the set of symbols that you
want to have exported, and process all other symbols with
  '#define foo libvirt_foo'

This approach is more robust, but requires to compile all *.o files
twice: Once with the initial settings (no #define), and once for real.

This approach is implemented in libunistring. Look at the config.h rule
in this Makefile.am [1]. There are two auxiliary scripts: 'declared.sh' [2]
extracts the symbols from a .h file (assuming a particular coding style).
'exported.sh' [3] extracts te symbols of a .o file.



I don't want to rush anything, but I see that libvirt 0.10 will be 
coming out soon and I don't think this has been corrected?


Right now this means that libvirt is not usable on Ubuntu 12.04 systems 
when you want to use the secrets of libvirt.


Is it feasible to have this fixed before 0.10 comes out?

Wido


Bruno

[1] 
http://git.savannah.gnu.org/gitweb/?p=libunistring.git;a=blob;f=lib/Makefile.am
[2] 
http://git.savannah.gnu.org/gitweb/?p=libunistring.git;a=blob;f=lib/declared.sh
[3] 
http://git.savannah.gnu.org/gitweb/?p=libunistring.git;a=blob;f=lib/exported.sh.in



--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH v2] Update xml schemas according to libvirt source

2012-08-02 Thread Ján Tomko
capability.rng: Guest features can be in any order.
nodedev.rng: Added driver element, capability phys_function and
virt_functions for PCI devices.
storagepool.rng: Owner or group ID can be -1.

schema tests: New capabilities and nodedev files; changed owner and
group to -1 in pool-dir.xml.
storage_conf: Print uid_t and gid_t as signed to storage pool XML.
---
v2: New tests and signed uid_t and gid_t printing. This feels slightly
less wrong than testing for 4294967295.
---
 docs/schemas/capability.rng|   76 ++--
 docs/schemas/nodedev.rng   |   37 ++
 docs/schemas/storagepool.rng   |   10 ++-
 src/conf/storage_conf.c|8 +-
 tests/capabilityschemadata/caps-test2.xml  |  122 
 .../pci_82579LM_network_adapter.xml|   17 +++
 tests/storagepoolxml2xmlin/pool-dir.xml|4 +-
 tests/storagepoolxml2xmlout/pool-dir.xml   |4 +-
 8 files changed, 231 insertions(+), 47 deletions(-)
 create mode 100644 tests/capabilityschemadata/caps-test2.xml
 create mode 100644 tests/nodedevschemadata/pci_82579LM_network_adapter.xml

diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
index 06ff685..c392e44 100644
--- a/docs/schemas/capability.rng
+++ b/docs/schemas/capability.rng
@@ -296,43 +296,45 @@
 
   define name='features'
 element name='features'
-  optional
-element name='pae'
-  empty/
-/element
-  /optional
-  optional
-element name='nonpae'
-  empty/
-/element
-  /optional
-  optional
-element name='ia64_be'
-  empty/
-/element
-  /optional
-  optional
-element name='acpi'
-  ref name='featuretoggle'/
-  empty/
-/element
-  /optional
-  optional
-element name='apic'
-  ref name='featuretoggle'/
-  empty/
-/element
-  /optional
-  optional
-element name='cpuselection'
-  empty/
-/element
-  /optional
-  optional
-element name='deviceboot'
-  empty/
-/element
-  /optional
+  interleave
+optional
+  element name='pae'
+empty/
+  /element
+/optional
+optional
+  element name='nonpae'
+empty/
+  /element
+/optional
+optional
+  element name='ia64_be'
+empty/
+  /element
+/optional
+optional
+  element name='acpi'
+ref name='featuretoggle'/
+empty/
+  /element
+/optional
+optional
+  element name='apic'
+ref name='featuretoggle'/
+empty/
+  /element
+/optional
+optional
+  element name='cpuselection'
+empty/
+  /element
+/optional
+optional
+  element name='deviceboot'
+empty/
+  /element
+/optional
+  /interleave
 /element
   /define
 
diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng
index a73c2e5..c07a97d 100644
--- a/docs/schemas/nodedev.rng
+++ b/docs/schemas/nodedev.rng
@@ -15,6 +15,12 @@
 element name=parenttext//element
   /optional
 
+  optional
+element name=driver
+  element name=nametext//element
+/element
+  /optional
+
   zeroOrMore
 ref name=capability/
   /zeroOrMore
@@ -115,6 +121,28 @@
   /choice
 /element
 
+optional
+  element name='capability'
+attribute name='type'
+  valuephys_function/value
+/attribute
+optional
+  ref name='address'/
+/optional
+  /element
+/optional
+
+optional
+  element name='capability'
+attribute name='type'
+  valuevirt_functions/value
+/attribute
+optional
+  ref name='address'/
+/optional
+  /element
+/optional
+
   /define
 
   define name='capusbdev'
@@ -369,6 +397,15 @@
 /element
   /define
 
+  define name='address'
+element name='address'
+  attribute name='domain'ref name='hexuint'//attribute
+  attribute name='bus'ref name='hexuint'//attribute
+  attribute name='slot'ref name='hexuint'//attribute
+  attribute name='function'ref name='hexuint'//attribute
+/element
+  /define
+
   define name='hexuint'
 data type='string'
   param name=pattern(0x)?[0-9a-f]+/param
diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng
index 039798a..983f664 100644
--- a/docs/schemas/storagepool.rng
+++ b/docs/schemas/storagepool.rng
@@ -178,10 +178,16 @@
   ref name='unsignedInt'/
 /element
 element name='owner'
-  ref name='unsignedInt'/
+  choice
+ref name='unsignedInt'/
+value-1/value
+  

Re: [libvirt] namespace clean shared libraries

2012-08-02 Thread Daniel P. Berrange
On Thu, Aug 02, 2012 at 01:18:12PM +0200, Wido den Hollander wrote:
 On 07/08/2012 07:51 PM, Bruno Haible wrote:
 Daniel P. Berrange wrote:
 If its better to just do it in libvirt config.h, then we
 can do that too
 
 Yes, doing '#define foo libvirt_foo' in config.h is the preferred way
 of achieving a namespace clean shared library.
 
 There are two ways to generate these #defines:
 
 1) You collect manually, on various systems, the set of symbols that you
 don't want to clash with symbols from other shared libraries. You need
 to do this on various systems, because gnulib may define functions
 'rpl_fflush' or 'dprintf' on some systems and not on others.
 
 2) You collect, from a set of header files, the set of symbols that you
 want to have exported, and process all other symbols with
   '#define foo libvirt_foo'
 
 This approach is more robust, but requires to compile all *.o files
 twice: Once with the initial settings (no #define), and once for real.
 
 This approach is implemented in libunistring. Look at the config.h rule
 in this Makefile.am [1]. There are two auxiliary scripts: 'declared.sh' 
  [2]
 extracts the symbols from a .h file (assuming a particular coding style).
 'exported.sh' [3] extracts te symbols of a .o file.
 
 
 I don't want to rush anything, but I see that libvirt 0.10 will be
 coming out soon and I don't think this has been corrected?
 
 Right now this means that libvirt is not usable on Ubuntu 12.04
 systems when you want to use the secrets of libvirt.
 
 Is it feasible to have this fixed before 0.10 comes out?

Try applying this patch to your source tree

diff --git a/configure.ac b/configure.ac
index 6b189db..4f906bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2876,6 +2876,10 @@ test x$lv_cv_static_analysis = xyes  t=1
 AC_DEFINE_UNQUOTED([STATIC_ANALYSIS], [$t],
   [Define to 1 when performing static analysis.])
 
+AC_DEFINE_UNQUOTED([isbase64],[gnulib_isbase64],[Hack to avoid symbol clash])
+AC_DEFINE_UNQUOTED([base64_encode],[gnulib_base64_encode],[Hack to avoid 
symbol clash])
+AC_DEFINE_UNQUOTED([base64_encode_alloc],[gnulib_base64_encode_alloc],[Hack to 
avoid symbol clash])
+
 AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \
  docs/schemas/Makefile \
  gnulib/lib/Makefile \


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [glib PATCH V5] Add bindings for virDomainRestore*()

2012-08-02 Thread Christophe Fergeau
On Tue, Jul 31, 2012 at 12:41:11PM +0200, Zeeshan Ali (Khattak) wrote:
  +static void restore_domain_from_file_data_free(RestoreDomainFromFileData 
  *data)
  +{
  +g_free(data-filename);
  +if (data-custom_conf != NULL)
  +g_object_unref(data-custom_conf);
 
 Actually you can make use of g_clear_object here as you did in
 gvir_domain_save_to_file() patch.

Imo this is a matter of preferences, iirc g_clear_object is a very hammer
performance-wise, so I'm fine with code using g_object_unref directly.

  +
  +if (!gvir_connection_restore_domain_from_file(conn, data-filename,
  +  data-custom_conf,
  +  data-flags, err))
 
 Each argument on a newline when breaking function call on multiple lines.

I generally favour more balanced blocks, even if this means several
arguments on a break-up line. Just a cosmetic detail, no strong feeling
either, but imo this is more a matter of preference than a hard rule we
should enforce.

Christophe


pgph5SHWhadfI.pgp
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [libvirt-glib 1/2] Add async variant of gvir_domain_resume()

2012-08-02 Thread Christophe Fergeau
On Mon, Jul 30, 2012 at 06:30:27PM +0200, Zeeshan Ali (Khattak) wrote:
 From: Zeeshan Ali (Khattak) zeesha...@gnome.org
 
 ---
  libvirt-gobject/libvirt-gobject-domain.c | 56 
 
  libvirt-gobject/libvirt-gobject-domain.h |  7 
  libvirt-gobject/libvirt-gobject.sym  |  2 ++
  3 files changed, 65 insertions(+)
 
 diff --git a/libvirt-gobject/libvirt-gobject-domain.c 
 b/libvirt-gobject/libvirt-gobject-domain.c
 index 861f713..d6d804d 100644
 --- a/libvirt-gobject/libvirt-gobject-domain.c
 +++ b/libvirt-gobject/libvirt-gobject-domain.c
 @@ -446,6 +446,62 @@ gboolean gvir_domain_resume(GVirDomain *dom,
  return TRUE;
  }
  
 +static void
 +gvir_domain_resume_helper(GSimpleAsyncResult *res,
 +  GObject *object,
 +  GCancellable *cancellable G_GNUC_UNUSED)
 +{
 +GVirDomain *dom = GVIR_DOMAIN(object);
 +GError *err = NULL;
 +
 +if (!gvir_domain_resume(dom, err))
 +g_simple_async_result_take_error(res, err);
 +}
 +
 +/**
 + * gvir_domain_resume_async:
 + * @dom: the domain

Maybe the domain to resume

ACK.

Christophe


pgpVWettAtMSQ.pgp
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH v2 2/3] qemu: Add support for S3/S4 state configuration

2012-08-02 Thread Martin Kletzander
This patch adds support for running qemu guests with the required
parameters to forcefully enable or disable BIOS advertising of S3 and
S4 states.  The support for this is added to capabilities and there is
also a qemu command parameter parsing implemented.
---
 src/qemu/qemu_capabilities.c |7 +++
 src/qemu/qemu_capabilities.h |2 +
 src/qemu/qemu_command.c  |  103 ++
 src/qemu/qemu_driver.c   |   17 +++
 4 files changed, 129 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 85c49a2..b4a662f 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -169,6 +169,8 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
   virtio-s390,
   balloon-event,

+  disable-s3, /* 100 */
+  disable-s4,
 );

 struct qemu_feature_flags {
@@ -1396,6 +1398,7 @@ qemuCapsExtractDeviceStr(const char *qemu,
  -device, virtio-blk-pci,?,
  -device, virtio-net-pci,?,
  -device, scsi-disk,?,
+ -device, PIIX4_PM,?,
  NULL);
 /* qemu -help goes to stdout, but qemu -device ? goes to stderr.  */
 virCommandSetErrorBuffer(cmd, output);
@@ -1487,6 +1490,10 @@ qemuCapsParseDeviceStr(const char *str, virBitmapPtr 
flags)
 qemuCapsSet(flags, QEMU_CAPS_SCSI_CD);
 if (strstr(str, ide-cd))
 qemuCapsSet(flags, QEMU_CAPS_IDE_CD);
+if (strstr(str, PIIX4_PM.disable_s3=))
+qemuCapsSet(flags, QEMU_CAPS_DISABLE_S3);
+if (strstr(str, PIIX4_PM.disable_s4=))
+qemuCapsSet(flags, QEMU_CAPS_DISABLE_S4);

 return 0;
 }
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index e8251dc..a909f67 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -135,6 +135,8 @@ enum qemuCapsFlags {
 QEMU_CAPS_NEC_USB_XHCI   = 97, /* -device nec-usb-xhci */
 QEMU_CAPS_VIRTIO_S390= 98, /* -device virtio-*-s390 */
 QEMU_CAPS_BALLOON_EVENT  = 99, /* Async event for balloon changes */
+QEMU_CAPS_DISABLE_S3= 100, /* S3 BIOS Advertisement on/off */
+QEMU_CAPS_DISABLE_S4= 101, /* S4 BIOS Advertisement on/off */

 QEMU_CAPS_LAST,   /* this must always be the last item */
 };
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 6ad65a6..a30c2f1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4692,6 +4692,48 @@ qemuBuildCommandLine(virConnectPtr conn,
 virCommandAddArg(cmd, -no-acpi);
 }

+if (def-pm.s3) {
+if (qemuCapsGet(qemuCaps, QEMU_CAPS_DISABLE_S3)) {
+if (def-pm.s3 == VIR_DOMAIN_PM_STATE_ON)
+virCommandAddArgList(cmd,
+ -global,
+ PIIX4_PM.disable_s3=0,
+ NULL);
+
+else if (def-pm.s3 == VIR_DOMAIN_PM_STATE_OFF)
+virCommandAddArgList(cmd,
+ -global,
+ PIIX4_PM.disable_s3=1,
+ NULL);
+
+} else {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   %s, _(setting ACPI S3 not supported));
+goto error;
+}
+}
+
+if (def-pm.s4) {
+if (qemuCapsGet(qemuCaps, QEMU_CAPS_DISABLE_S4)) {
+if (def-pm.s4 == VIR_DOMAIN_PM_STATE_ON)
+virCommandAddArgList(cmd,
+ -global,
+ PIIX4_PM.disable_s4=0,
+ NULL);
+
+else if (def-pm.s4 == VIR_DOMAIN_PM_STATE_OFF)
+virCommandAddArgList(cmd,
+ -global,
+ PIIX4_PM.disable_s4=1,
+ NULL);
+
+} else {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   %s, _(setting ACPI S4 not supported));
+goto error;
+}
+}
+
 if (!def-os.bootloader) {
 /*
  * We prefer using explicit bootindex=N parameters for predictable
@@ -8199,6 +8241,67 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,

 *monConfig = chr;
 }
+} else if (STREQ(arg, -global) 
+   STRPREFIX(progargv[i + 1], PIIX4_PM.disable_s3=)) {
+/* We want to parse only the known -global parameters,
+ * so the ones that we don't know are still added to the
+ * namespace */
+WANT_VALUE();
+
+val += strlen(PIIX4_PM.disable_s3=);
+
+if (strlen(val) != 1) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(invalid value for 

[libvirt] [PATCH v2 1/3] Add per-guest S3/S4 state configuration

2012-08-02 Thread Martin Kletzander
There is a new pm/ element implemented that can control what ACPI
sleeping states will be advertised by BIOS and allowed to be switched
to by libvirt. The default keeps defaults on hypervisor, otherwise
forces chosen setting.
---
 docs/schemas/domaincommon.rng |   33 ++
 src/conf/domain_conf.c|   44 +
 src/conf/domain_conf.h|   14 +
 src/libvirt_private.syms  |2 +
 4 files changed, 93 insertions(+), 0 deletions(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index c85d763..657d723 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -53,6 +53,9 @@
 ref name=features/
 ref name=termination/
 optional
+  ref name=pm/
+/optional
+optional
   ref name=devices/
 /optional
 optional
@@ -2192,6 +2195,36 @@
 /choice
   /define
   !--
+  Control ACPI sleep states (dis)allowed for the domain
+  For each of the states the following rules apply:
+  on: the state will be forcefully enabled
+  off: the state will be forcefully disabled
+  not specified: hypervisor will be left to decide its defaults
+  --
+  define name=pm
+element name=pm
+  interleave
+optional
+  attribute name=s3
+ref name=suspendChoices/
+  /attribute
+/optional
+optional
+  attribute name=s4
+ref name=suspendChoices/
+  /attribute
+/optional
+  /interleave
+  empty/
+/element
+  /define
+  define name=suspendChoices
+choice
+  valueon/value
+  valueoff/value
+/choice
+  /define
+  !--
   Specific setup for a qemu emulated character device.  Note: this
   definition doesn't fully specify the constraints on this node.
 --
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 43b3f80..7a8279b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -124,6 +124,11 @@ VIR_ENUM_IMPL(virDomainLifecycleCrash, 
VIR_DOMAIN_LIFECYCLE_CRASH_LAST,
   coredump-destroy,
   coredump-restart)

+VIR_ENUM_IMPL(virDomainPMState, VIR_DOMAIN_PM_STATE_LAST,
+  default,
+  on,
+  off)
+
 VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST,
   none,
   disk,
@@ -8381,6 +8386,19 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr 
caps,
virDomainLifecycleCrashTypeFromString)  0)
 goto error;

+if (virXPathNode(./pm, ctxt)) {
+tmp = virXPathString(string(./pm/@s3), ctxt);
+if (tmp) {
+def-pm.s3 = virDomainPMStateTypeFromString(tmp);
+VIR_FREE(tmp);
+}
+tmp = virXPathString(string(./pm/@s4), ctxt);
+if (tmp) {
+def-pm.s4 = virDomainPMStateTypeFromString(tmp);
+VIR_FREE(tmp);
+}
+}
+
 tmp = virXPathString(string(./clock/@offset), ctxt);
 if (tmp) {
 if ((def-clock.offset = virDomainClockOffsetTypeFromString(tmp))  0) 
{
@@ -13061,6 +13079,32 @@ virDomainDefFormatInternal(virDomainDefPtr def,
 virDomainLifecycleCrashTypeToString)  0)
 goto cleanup;

+if (def-pm.s3 || def-pm.s4) {
+virBufferAddLit(buf,   pm);
+
+if (def-pm.s3) {
+const char *tmp = virDomainPMStateTypeToString(def-pm.s3);
+if (!tmp) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(unexpected PM state %d), def-pm.s3);
+goto cleanup;
+}
+virBufferAsprintf(buf,  s3='%s', tmp);
+}
+
+if (def-pm.s4) {
+const char *tmp = virDomainPMStateTypeToString(def-pm.s4);
+if (!tmp) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(unexpected PM state %d), def-pm.s4);
+goto cleanup;
+}
+virBufferAsprintf(buf,  s4='%s', tmp);
+}
+
+virBufferAddLit(buf, /\n);
+}
+
 virBufferAddLit(buf,   devices\n);

 virBufferEscapeString(buf, emulator%s/emulator\n,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9fdda78..3eddd5f 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1372,6 +1372,14 @@ enum virDomainLifecycleCrashAction {
 VIR_DOMAIN_LIFECYCLE_CRASH_LAST
 };

+enum virDomainPMState {
+VIR_DOMAIN_PM_STATE_DEFAULT = 0,
+VIR_DOMAIN_PM_STATE_ON,
+VIR_DOMAIN_PM_STATE_OFF,
+
+VIR_DOMAIN_PM_STATE_LAST,
+};
+
 enum virDomainBIOSUseserial {
 VIR_DOMAIN_BIOS_USESERIAL_DEFAULT = 0,
 VIR_DOMAIN_BIOS_USESERIAL_YES,
@@ -1618,6 +1626,11 @@ struct _virDomainDef {
 int onPoweroff;
 int onCrash;

+struct {
+int s3;
+int s4;
+} pm;
+
 virDomainOSDef os;
 char 

[libvirt] [PATCH v2 3/3] tests: Add tests for qemu S3/S4 state configuration

2012-08-02 Thread Martin Kletzander
Few tests were added which are checking whether the parsing of the xml
and command-line arguments is working and compatible with each other.
---
 tests/qemuargv2xmltest.c   |3 ++
 .../qemuxml2argv-misc-disable-s3.args  |4 +++
 .../qemuxml2argv-misc-disable-s3.xml   |   27 
 .../qemuxml2argv-misc-disable-suspends.args|4 +++
 .../qemuxml2argv-misc-disable-suspends.xml |   27 
 .../qemuxml2argv-misc-enable-s4.args   |4 +++
 .../qemuxml2argv-misc-enable-s4.xml|   27 
 tests/qemuxml2argvtest.c   |4 +++
 tests/qemuxml2xmltest.c|3 ++
 9 files changed, 103 insertions(+), 0 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.xml
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-enable-s4.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-enable-s4.xml

diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index 439218e..ad5f45b 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -205,6 +205,9 @@ mymain(void)
 /* Can't rountrip xenner arch */
 /*DO_TEST(input-xen);*/
 DO_TEST(misc-acpi);
+DO_TEST(misc-disable-s3);
+DO_TEST(misc-disable-suspends);
+DO_TEST(misc-enable-s4);
 DO_TEST(misc-no-reboot);
 DO_TEST(misc-uuid);
 DO_TEST(net-user);
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.args 
b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.args
new file mode 100644
index 000..dbee64d
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.args
@@ -0,0 +1,4 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S \
+-M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
+-no-acpi -global PIIX4_PM.disable_s3=1 -boot c -hda /dev/HostVG/QEMUGuest1 \
+-net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.xml
new file mode 100644
index 000..7938245
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.xml
@@ -0,0 +1,27 @@
+domain type='qemu'
+  nameQEMUGuest1/name
+  uuid8caaa98c-e7bf-5845-126a-1fc316bd1089/uuid
+  memory unit='KiB'219100/memory
+  currentMemory unit='KiB'219100/currentMemory
+  vcpu placement='static'1/vcpu
+  os
+type arch='i686' machine='pc'hvm/type
+boot dev='hd'/
+  /os
+  clock offset='utc'/
+  on_poweroffdestroy/on_poweroff
+  on_rebootrestart/on_reboot
+  on_crashdestroy/on_crash
+  pm s3='off'/
+  devices
+emulator/usr/bin/qemu/emulator
+disk type='block' device='disk'
+  source dev='/dev/HostVG/QEMUGuest1'/
+  target dev='hda' bus='ide'/
+  address type='drive' controller='0' bus='0' target='0' unit='0'/
+/disk
+controller type='usb' index='0'/
+controller type='ide' index='0'/
+memballoon model='virtio'/
+  /devices
+/domain
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.args 
b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.args
new file mode 100644
index 000..6f63d8b
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.args
@@ -0,0 +1,4 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S \
+-M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
+-no-acpi -global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 -boot c \
+-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.xml
new file mode 100644
index 000..0b28584
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.xml
@@ -0,0 +1,27 @@
+domain type='qemu'
+  nameQEMUGuest1/name
+  uuid8caaa98c-e7bf-5845-126a-1fc316bd1089/uuid
+  memory unit='KiB'219100/memory
+  currentMemory unit='KiB'219100/currentMemory
+  vcpu placement='static'1/vcpu
+  os
+type arch='i686' machine='pc'hvm/type
+boot dev='hd'/
+  /os
+  clock offset='utc'/
+  on_poweroffdestroy/on_poweroff
+  on_rebootrestart/on_reboot
+  on_crashdestroy/on_crash
+  pm s3='off' s4='off'/
+  devices
+emulator/usr/bin/qemu/emulator
+disk type='block' device='disk'
+  source dev='/dev/HostVG/QEMUGuest1'/
+  target dev='hda' bus='ide'/
+  address type='drive' controller='0' bus='0' target='0' unit='0'/
+/disk
+controller type='usb' index='0'/
+controller type='ide' index='0'/
+memballoon 

Re: [libvirt] [libvirt-glib 2/2] RFC: Make use of GUINT_TO_POINTER/GPOINTER_TO_UINT

2012-08-02 Thread Christophe Fergeau
On Mon, Jul 30, 2012 at 06:30:28PM +0200, Zeeshan Ali (Khattak) wrote:
 From: Zeeshan Ali (Khattak) zeesha...@gnome.org
 
 We create struct and a free function each time we need to pass a simple
 unsigned integer to an async function. Code can be simplified if we
 don't do that but rather use glib's API to convert to/from uint to
 pointer.

If I was writing such code, I'd probably go with GUINT_TO_POINTER, but
since it's written with a struct, and it's more consistent with other async
code, I'd keep it this way as it makes things more predictable and
readable. But if you really want to make this change, this is fine with me.

Christophe


pgp7CsD2yTXUW.pgp
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH v2 0/3] Per-guest S3/S4 configuration

2012-08-02 Thread Martin Kletzander
There is a way to tell qemu how (not) to advertise S3/S4 ACPI sleep
state capability to the guest OS. This series includes the capability
to set this in the XML and also covers all the handling from qemu
point of view including checking for the support, parameter parsing,
command building, checking before sending the signals through guest
agent and also tests.

--
v2:
 - Modified the patch to reflect danpb's notes (according to qemu
   people the setting the disable_s[34] parameter to 0/1 ensures that
   the states will be enabled/disabled respectively)

Martin Kletzander (3):
  Add per-guest S3/S4 state configuration
  qemu: Add support for S3/S4 state configuration
  tests: Add tests for qemu S3/S4 state configuration

 docs/schemas/domaincommon.rng  |   33 ++
 src/conf/domain_conf.c |   44 +
 src/conf/domain_conf.h |   14 +++
 src/libvirt_private.syms   |2 +
 src/qemu/qemu_capabilities.c   |7 ++
 src/qemu/qemu_capabilities.h   |2 +
 src/qemu/qemu_command.c|  103 
 src/qemu/qemu_driver.c |   17 +++
 tests/qemuargv2xmltest.c   |3 +
 .../qemuxml2argv-misc-disable-s3.args  |4 +
 .../qemuxml2argv-misc-disable-s3.xml   |   27 +
 .../qemuxml2argv-misc-disable-suspends.args|4 +
 .../qemuxml2argv-misc-disable-suspends.xml |   27 +
 .../qemuxml2argv-misc-enable-s4.args   |4 +
 .../qemuxml2argv-misc-enable-s4.xml|   27 +
 tests/qemuxml2argvtest.c   |4 +
 tests/qemuxml2xmltest.c|3 +
 17 files changed, 325 insertions(+), 0 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.xml
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-enable-s4.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-enable-s4.xml

--
1.7.8.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] QEMU 1.2 Test Day - August 16 2012

2012-08-02 Thread Stefan Hajnoczi
I have set up the QEMU 1.2 Testing wiki page and suggest August 16 as
the Test Day:

http://wiki.qemu.org/Planning/1.2/Testing

Test Day is an event for QEMU contributors and users to try out the
release candidate.  QEMU has a large feature matrix that is hard to
test by a single entity.  On Test Day everyone is encouraged to test
their favorite features, host OSes, and guest OSes to make sure that
the release candidate is stable.

Please add yourself to the http://wiki.qemu.org/Planning/1.2/Testing wiki page!

The Test Day is August 16 2012, one day after the planned -rc0
release.  On the day, use #qemu IRC on irc.oftc.net to chat about bugs
and update the wiki page with your pass/fail results.

There are usually -rc1, -rc2, ... follow-up release candidates.
Please retest those if you have time, especially if bugs you found are
supposed to be resolved.

Stefan

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] Remove reference to the ex future release 0.9.14

2012-08-02 Thread Daniel Veillard
On Thu, Aug 02, 2012 at 11:46:07AM +0100, Daniel P. Berrange wrote:
 On Thu, Aug 02, 2012 at 06:33:14PM +0800, Daniel Veillard wrote:
  On Thu, Aug 02, 2012 at 11:17:33AM +0100, Daniel P. Berrange wrote:
   We need to fix  libvirt_public.syms to refer to 0.10.0 instead of
   0.9.14. Likewise in some of the source files  docs we need to
   remove 0.9.14
  
  And replace it to the expected 0.10.0
  
  diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
  index c834577..f97c630 100644
  --- a/docs/formatdomain.html.in
  +++ b/docs/formatdomain.html.in
  @@ -780,7 +780,7 @@
   CPU model will fail. Supported values for codefallback/code
   attribute are: codeallow/code (this is the default), and
   codeforbid/code. The optional codevendor_id/code attribute
  -(span class=sinceSince 0.9.14/span)  can be used to set the
  +(span class=sinceSince 0.10.0/span)  can be used to set the
   vendor id seen by the guest. It must be exactly 12 characters long.
   If not set the vendor id of the host is used. Typical possible
   values are AuthenticAMD and GenuineIntel./dd
  diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
  index 5004182..e3ba119 100644
  --- a/src/libvirt_public.syms
  +++ b/src/libvirt_public.syms
  @@ -544,7 +544,7 @@ LIBVIRT_0.9.13 {
   virDomainSnapshotRef;
   } LIBVIRT_0.9.11;
   
  -LIBVIRT_0.9.14 {
  +LIBVIRT_0.10.0 {
   global:
   virDomainGetHostname;
   virConnectRegisterCloseCallback;
  diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
  index 4cc7f46..48b5219 100644
  --- a/src/openvz/openvz_driver.c
  +++ b/src/openvz/openvz_driver.c
  @@ -2170,7 +2170,7 @@ static virDriver openvzDriver = {
   .domainIsUpdated = openvzDomainIsUpdated, /* 0.8.6 */
   .isAlive = openvzIsAlive, /* 0.9.8 */
   .domainUpdateDeviceFlags = openvzDomainUpdateDeviceFlags, /* 0.9.13 */
  -.domainGetHostname = openvzDomainGetHostname, /* 0.9.14 */
  +.domainGetHostname = openvzDomainGetHostname, /* 0.10.0 */
   };
   
   int openvzRegister(void) {
  diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
  index 9354cb4..b9e2127 100644
  --- a/src/remote/remote_driver.c
  +++ b/src/remote/remote_driver.c
  @@ -5366,7 +5366,7 @@ static virDriver remote_driver = {
   .domainGetDiskErrors = remoteDomainGetDiskErrors, /* 0.9.10 */
   .domainSetMetadata = remoteDomainSetMetadata, /* 0.9.10 */
   .domainGetMetadata = remoteDomainGetMetadata, /* 0.9.10 */
  -.domainGetHostname = remoteDomainGetHostname, /* 0.9.14 */
  +.domainGetHostname = remoteDomainGetHostname, /* 0.10.0 */
   };
   
   static virNetworkDriver network_driver = {
 
 ACK identical to Eric's patch, but since his isn't pushed and he's
 not online yet, go ahead with yours

  Actually I pushed his because he had more details in the commit :-)

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] namespace clean shared libraries

2012-08-02 Thread Bruno Haible
Daniel P. Berrange wrote:
 Try applying this patch to your source tree
 
 diff --git a/configure.ac b/configure.ac
 index 6b189db..4f906bb 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -2876,6 +2876,10 @@ test x$lv_cv_static_analysis = xyes  t=1
  AC_DEFINE_UNQUOTED([STATIC_ANALYSIS], [$t],
[Define to 1 when performing static analysis.])
  
 +AC_DEFINE_UNQUOTED([isbase64],[gnulib_isbase64],[Hack to avoid symbol clash])
 +AC_DEFINE_UNQUOTED([base64_encode],[gnulib_base64_encode],[Hack to avoid 
 symbol clash])
 +AC_DEFINE_UNQUOTED([base64_encode_alloc],[gnulib_base64_encode_alloc],[Hack 
 to avoid symbol clash])
 +

Could you please use a prefix that is specific to libvirt, rather than
'gnulib_'? I mean, if two different libraries libvirt and libfoo use the
same prefix 'gnulib_', the symbols will *still* clash.

Bruno

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Change function signature for creating new lock manager instances

2012-08-02 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

To allow a virLockManagerPtr to be created directly from a
driver table struct, replace the virLockManagerPluginPtr parameter
with a virLockDriverPtr parameter.

* src/locking/domain_lock.c, src/locking/lock_manager.c,
  src/locking/lock_manager.h: Replace plugin param with
  a driver in virLockManagerNew
---
 src/locking/domain_lock.c  |  2 +-
 src/locking/lock_manager.c | 31 +++
 src/locking/lock_manager.h |  3 ++-
 3 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/src/locking/domain_lock.c b/src/locking/domain_lock.c
index 55f5640..ba49f9c 100644
--- a/src/locking/domain_lock.c
+++ b/src/locking/domain_lock.c
@@ -124,7 +124,7 @@ static virLockManagerPtr 
virDomainLockManagerNew(virLockManagerPluginPtr plugin,
 
 memcpy(params[0].value.uuid, dom-def-uuid, VIR_UUID_BUFLEN);
 
-if (!(lock = virLockManagerNew(plugin,
+if (!(lock = virLockManagerNew(virLockManagerPluginGetDriver(plugin),
VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN,
ARRAY_CARDINALITY(params),
params,
diff --git a/src/locking/lock_manager.c b/src/locking/lock_manager.c
index 18e739e..5f65ecf 100644
--- a/src/locking/lock_manager.c
+++ b/src/locking/lock_manager.c
@@ -39,11 +39,11 @@
 
 #define VIR_FROM_THIS VIR_FROM_LOCKING
 
-#define CHECK_PLUGIN(field, errret)  \
-if (!plugin-driver-field) {\
-virReportError(VIR_ERR_INTERNAL_ERROR, \
-   _(Missing '%s' field in lock manager driver), \
-   #field);\
+#define CHECK_DRIVER(field, errret)  \
+if (!driver-field) {\
+virLockError(VIR_ERR_INTERNAL_ERROR, \
+ _(Missing '%s' field in lock manager driver), \
+ #field);\
 return errret;   \
 }
 
@@ -265,9 +265,16 @@ bool virLockManagerPluginUsesState(virLockManagerPluginPtr 
plugin)
 }
 
 
+virLockDriverPtr virLockManagerPluginGetDriver(virLockManagerPluginPtr plugin)
+{
+VIR_DEBUG(plugin=%p, plugin);
+
+return plugin-driver;
+}
+
 /**
  * virLockManagerNew:
- * @plugin: the plugin implementation to use
+ * @driver: the lock manager implementation to use
  * @type: the type of process to be supervised
  * @flags: optional flags, currently unused
  *
@@ -276,27 +283,27 @@ bool 
virLockManagerPluginUsesState(virLockManagerPluginPtr plugin)
  *
  * Returns a new lock manager context
  */
-virLockManagerPtr virLockManagerNew(virLockManagerPluginPtr plugin,
+virLockManagerPtr virLockManagerNew(virLockDriverPtr driver,
 unsigned int type,
 size_t nparams,
 virLockManagerParamPtr params,
 unsigned int flags)
 {
 virLockManagerPtr lock;
-VIR_DEBUG(plugin=%p type=%u nparams=%zu params=%p flags=%x,
-  plugin, type, nparams, params, flags);
+VIR_DEBUG(driver=%p type=%u nparams=%zu params=%p flags=%x,
+  driver, type, nparams, params, flags);
 virLockManagerLogParams(nparams, params);
 
-CHECK_PLUGIN(drvNew, NULL);
+CHECK_DRIVER(drvNew, NULL);
 
 if (VIR_ALLOC(lock)  0) {
 virReportOOMError();
 return NULL;
 }
 
-lock-driver = plugin-driver;
+lock-driver = driver;
 
-if (plugin-driver-drvNew(lock, type, nparams, params, flags)  0) {
+if (driver-drvNew(lock, type, nparams, params, flags)  0) {
 VIR_FREE(lock);
 return NULL;
 }
diff --git a/src/locking/lock_manager.h b/src/locking/lock_manager.h
index b548d45..25c7f7f 100644
--- a/src/locking/lock_manager.h
+++ b/src/locking/lock_manager.h
@@ -37,8 +37,9 @@ void virLockManagerPluginUnref(virLockManagerPluginPtr 
plugin);
 const char *virLockManagerPluginGetName(virLockManagerPluginPtr plugin);
 bool virLockManagerPluginUsesState(virLockManagerPluginPtr plugin);
 
+virLockDriverPtr virLockManagerPluginGetDriver(virLockManagerPluginPtr plugin);
 
-virLockManagerPtr virLockManagerNew(virLockManagerPluginPtr plugin,
+virLockManagerPtr virLockManagerNew(virLockDriverPtr driver,
 unsigned int type,
 size_t nparams,
 virLockManagerParamPtr params,
-- 
1.7.11.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Add APIs for obtaining the unique ID of LVM SCSI volumes

2012-08-02 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

Both LVM volumes and SCSI LUNs have a globally unique
identifier associated with them. It is useful to be able
to query this identifier to then perform disk locking,
rather than try to figure out a stable pathname.
---
 src/util/storage_file.c | 93 +
 src/util/storage_file.h |  3 ++
 2 files changed, 96 insertions(+)

diff --git a/src/util/storage_file.c b/src/util/storage_file.c
index f38aa8e..56fd322 100644
--- a/src/util/storage_file.c
+++ b/src/util/storage_file.c
@@ -24,6 +24,7 @@
 #include config.h
 #include storage_file.h
 
+#include command.h
 #include sys/stat.h
 #include unistd.h
 #include fcntl.h
@@ -38,6 +39,7 @@
 #include virterror_internal.h
 #include logging.h
 #include virfile.h
+#include c-ctype.h
 
 #define VIR_FROM_THIS VIR_FROM_STORAGE
 
@@ -1073,3 +1075,94 @@ int virStorageFileIsClusterFS(const char *path)
 VIR_STORAGE_FILE_SHFS_GFS2 |
 VIR_STORAGE_FILE_SHFS_OCFS);
 }
+
+#ifdef LVS
+const char *virStorageFileGetLVMKey(const char *path)
+{
+/*
+ *  # lvs --noheadings --unbuffered --nosuffix --options uuid LVNAME
+ *06UgP5-2rhb-w3Bo-3mdR-WeoL-pytO-SAa2ky
+ */
+char *key = NULL;
+virCommandPtr cmd = virCommandNewArgList(
+LVS,
+--noheadings, --unbuffered, --nosuffix,
+--options, uuid, path,
+NULL
+);
+
+/* Run the program and capture its output */
+virCommandSetOutputBuffer(cmd, key);
+if (virCommandRun(cmd, NULL)  0)
+goto cleanup;
+
+if (key) {
+char *nl;
+char *tmp = key;
+
+/* Find first non-space character */
+while (*tmp  c_isspace(*tmp)) {
+tmp++;
+}
+/* Kill leading spaces */
+if (tmp != key)
+memmove(key, tmp, strlen(tmp)+1);
+
+/* Kill trailing newline */
+if ((nl = strchr(key, '\n')))
+*nl = '\0';
+}
+
+if (key  STREQ(key, ))
+VIR_FREE(key);
+
+cleanup:
+virCommandFree(cmd);
+
+return key;
+}
+#else
+const char *virStorageFileGetLVMKey(const char *path)
+{
+virReportSystemError(ENOSYS, _(Unable to get LVM key for %s), path);
+return NULL;
+}
+#endif
+
+#ifdef HAVE_UDEV
+const char *virStorageFileGetSCSIKey(const char *path)
+{
+char *key = NULL;
+virCommandPtr cmd = virCommandNewArgList(
+/lib/udev/scsi_id,
+--replace-whitespace,
+--whitelisted,
+--device, path,
+NULL
+);
+
+/* Run the program and capture its output */
+virCommandSetOutputBuffer(cmd, key);
+if (virCommandRun(cmd, NULL)  0)
+goto cleanup;
+
+if (key  STRNEQ(key, )) {
+char *nl = strchr(key, '\n');
+if (nl)
+*nl = '\0';
+} else {
+VIR_FREE(key);
+}
+
+cleanup:
+virCommandFree(cmd);
+
+return key;
+}
+#else
+const char *virStorageFileGetSCSIKey(const char *path)
+{
+virReportSystemError(ENOSYS, _(Unable to get SCSI key for %s), path);
+return NULL;
+}
+#endif
diff --git a/src/util/storage_file.h b/src/util/storage_file.h
index 1fbe08e..99a5e36 100644
--- a/src/util/storage_file.h
+++ b/src/util/storage_file.h
@@ -86,4 +86,7 @@ int virStorageFileIsClusterFS(const char *path);
 int virStorageFileIsSharedFSType(const char *path,
  int fstypes);
 
+const char *virStorageFileGetLVMKey(const char *path);
+const char *virStorageFileGetSCSIKey(const char *path);
+
 #endif /* __VIR_STORAGE_FILE_H__ */
-- 
1.7.11.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v2][TCK 2/2] Add test for memory set and get

2012-08-02 Thread Guannan Ren

On 08/01/2012 06:01 PM, Kyla Zhang wrote:

Add test for memory/maxmem set and get on domain running/shutdown
---
  scripts/domain/310-memory-set-get.t |   98 +++
  1 files changed, 98 insertions(+), 0 deletions(-)
  create mode 100644 scripts/domain/310-memory-set-get.t

diff --git a/scripts/domain/310-memory-set-get.t 
b/scripts/domain/310-memory-set-get.t
new file mode 100644
index 000..71886a6
--- /dev/null
+++ b/scripts/domain/310-memory-set-get.t
@@ -0,0 +1,98 @@
+# -*- perl -*-
+#
+# Copyright (C) 2012-2013 Red Hat, Inc.
+# Copyright (C) 2012-2013 Kyla Zhang weiz...@redhat.com
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file LICENSE distributed along with this file provides full
+# details of the terms and conditions
+#
+
+=pod
+
+=head1 NAME
+
+domain/310-memory-set-get.t: test set and get memory/max memory


 Could we use small number rather than 310.


+
+=head1 DESCRIPTION
+
+The test case validates that the set memory, set max memory and get
+max memory works well for domain.


  The testcase validates the basic function of domain memory 
balloon via

  setting its value of current memory, max memory.


+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests = 15;
+
+use Sys::Virt::TCK;
+use Sys::Virt::TCK::NetworkHelpers;
+use Test::Exception;
+use File::Spec::Functions qw(catfile catdir rootdir);
+
+my $tck = Sys::Virt::TCK-new();
+my $conn = eval { $tck-setup(); };
+BAIL_OUT failed to setup test harness: $@ if $@;
+END { $tck-cleanup if $tck; }
+
+diag Define a new real domain, default memory is 1048576;


my $current_mem = 1048576;
my $max_mem = 1572864;
my $config_mem = 924288;
diag Defing a guest with memory size $current_mem KiB;



+my $dom_name =tck310memtest;


   $dom_name = tckmemballoon



+
+my $dom = prepare_test_disk_and_vm($tck, $conn, $dom_name);
+
+diag Set max memory for domain;


diag Setting maximum memory for inactive domain



+lives_ok(sub { $dom-set_max_memory(1572864) }, Set max memory succeed);



 lives_ok(sub { $dom-set_max_memory($max_mem) }, Set max 
memory $max_mem);




+
+diag Get max memory for domain when domain is inactive;


 diag Get maximum memory from the inactive domain;



+is($dom-get_max_memory(), 1572864, Get max memory is same as set value 
1572864);


  is($dom-get_max_memory(),  $max_mem, Got max memory 
$max_mem);




+
+diag Start inactive domain;


diag Starting domain;



+$dom-create;
+ok($dom-get_id()  0, running domain has an ID  0);
+sleep(30);
+
+diag Set memory for current state;


   diag Setting  memory with flag MEM_CONFIG;



+lives_ok(sub { $dom-set_memory(924288, Sys::Virt::Domain::MEM_CONFIG) }, Set 
memory succeed in persistent config);


 lives_ok(sub { $dom-set_memory($config_mem, 
Sys::Virt::Domain::MEM_CONFIG) }, Set persistent memory value 
$config_mem);




+
+diag get memory of running domain;


diag Get current memory;


+is($dom-get_info()-{memory}, 1048576, Get current memory is 1048576);
+
+diag Get max memory for domain when domain is active;
+is($dom-get_max_memory(), 1572864, Get max memory is same as set value 
1572864);
+
+diag Set memory for current state;
+lives_ok(sub { $dom-set_memory(724288, Sys::Virt::Domain::MEM_CURRENT) }, Set 
memory succeed in current state);
+sleep(3);
+
+diag Check memory of running domain;
+is($dom-get_info()-{memory}, 724288, Get current memory is same as set value 
724288);
+
+diag Set memory for live state;
+lives_ok(sub { $dom-set_memory(824288, Sys::Virt::Domain::MEM_LIVE) }, Set 
memory succeed in live state);
+sleep(3);
+
+diag Check memory of running domain;
+is($dom-get_info()-{memory}, 824288, Get current memory is same as set value 
824288);
+
+diag Try setting max memory when domain is running;
+ok_error(sub { $dom-set_max_memory(1048576) }, not allowed to set max memory 
when domain is running);
+
+diag Destroying the transient domain;
+$dom-destroy;
+
+diag Check memory of shutdown domain;
+is($dom-get_info()-{memory}, 924288, Get memory is 624288 when domain is 
shutdown);
+
+diag Set max memory with set_memory;
+lives_ok(sub { $dom-set_memory(1148576, Sys::Virt::Domain::MEM_MAXIMUM) }, Set 
max memory succeed with set_memory);
+
+diag Get max memory for domain;
+is($dom-get_info()-{maxMem}, 1148576, Get max memory is same as set value 
1148576);
+
+diag Try setting live state memory when domain is shutdown;
+ok_error(sub { $dom-set_memory(824288, Sys::Virt::Domain::MEM_LIVE) }, not 
allowed to set live state memory when domain is shutdown);



 Using variable make code maintain easier.
 Output more simple and concise log.

 Testing scenario is good. hope v3 version.

 Guannan Ren

--

Re: [libvirt] namespace clean shared libraries

2012-08-02 Thread Wido den Hollander

On 08/02/2012 01:37 PM, Daniel P. Berrange wrote:

On Thu, Aug 02, 2012 at 01:18:12PM +0200, Wido den Hollander wrote:

On 07/08/2012 07:51 PM, Bruno Haible wrote:

Daniel P. Berrange wrote:

If its better to just do it in libvirt config.h, then we
can do that too


Yes, doing '#define foo libvirt_foo' in config.h is the preferred way
of achieving a namespace clean shared library.

There are two ways to generate these #defines:

1) You collect manually, on various systems, the set of symbols that you
don't want to clash with symbols from other shared libraries. You need
to do this on various systems, because gnulib may define functions
'rpl_fflush' or 'dprintf' on some systems and not on others.

2) You collect, from a set of header files, the set of symbols that you
want to have exported, and process all other symbols with
  '#define foo libvirt_foo'

This approach is more robust, but requires to compile all *.o files
twice: Once with the initial settings (no #define), and once for real.

This approach is implemented in libunistring. Look at the config.h rule
in this Makefile.am [1]. There are two auxiliary scripts: 'declared.sh' [2]
extracts the symbols from a .h file (assuming a particular coding style).
'exported.sh' [3] extracts te symbols of a .o file.



I don't want to rush anything, but I see that libvirt 0.10 will be
coming out soon and I don't think this has been corrected?

Right now this means that libvirt is not usable on Ubuntu 12.04
systems when you want to use the secrets of libvirt.

Is it feasible to have this fixed before 0.10 comes out?


Try applying this patch to your source tree

diff --git a/configure.ac b/configure.ac
index 6b189db..4f906bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2876,6 +2876,10 @@ test x$lv_cv_static_analysis = xyes  t=1
  AC_DEFINE_UNQUOTED([STATIC_ANALYSIS], [$t],
[Define to 1 when performing static analysis.])

+AC_DEFINE_UNQUOTED([isbase64],[gnulib_isbase64],[Hack to avoid symbol clash])
+AC_DEFINE_UNQUOTED([base64_encode],[gnulib_base64_encode],[Hack to avoid 
symbol clash])
+AC_DEFINE_UNQUOTED([base64_encode_alloc],[gnulib_base64_encode_alloc],[Hack to 
avoid symbol clash])
+
  AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \
   docs/schemas/Makefile \
   gnulib/lib/Makefile \


Yes, that works for me. The secrets are working on Ubuntu 12.04.

Thanks,

Wido




Regards,
Daniel



--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] namespace clean shared libraries

2012-08-02 Thread Daniel P. Berrange
On Thu, Aug 02, 2012 at 03:14:27PM +0200, Wido den Hollander wrote:
 On 08/02/2012 01:37 PM, Daniel P. Berrange wrote:
 On Thu, Aug 02, 2012 at 01:18:12PM +0200, Wido den Hollander wrote:
 On 07/08/2012 07:51 PM, Bruno Haible wrote:
 Daniel P. Berrange wrote:
 If its better to just do it in libvirt config.h, then we
 can do that too
 
 Yes, doing '#define foo libvirt_foo' in config.h is the preferred way
 of achieving a namespace clean shared library.
 
 There are two ways to generate these #defines:
 
 1) You collect manually, on various systems, the set of symbols that you
 don't want to clash with symbols from other shared libraries. You need
 to do this on various systems, because gnulib may define functions
 'rpl_fflush' or 'dprintf' on some systems and not on others.
 
 2) You collect, from a set of header files, the set of symbols that you
 want to have exported, and process all other symbols with
   '#define foo libvirt_foo'
 
 This approach is more robust, but requires to compile all *.o files
 twice: Once with the initial settings (no #define), and once for real.
 
 This approach is implemented in libunistring. Look at the config.h rule
 in this Makefile.am [1]. There are two auxiliary scripts: 
  'declared.sh' [2]
 extracts the symbols from a .h file (assuming a particular coding 
  style).
 'exported.sh' [3] extracts te symbols of a .o file.
 
 
 I don't want to rush anything, but I see that libvirt 0.10 will be
 coming out soon and I don't think this has been corrected?
 
 Right now this means that libvirt is not usable on Ubuntu 12.04
 systems when you want to use the secrets of libvirt.
 
 Is it feasible to have this fixed before 0.10 comes out?
 
 Try applying this patch to your source tree
 
 diff --git a/configure.ac b/configure.ac
 index 6b189db..4f906bb 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -2876,6 +2876,10 @@ test x$lv_cv_static_analysis = xyes  t=1
   AC_DEFINE_UNQUOTED([STATIC_ANALYSIS], [$t],
 [Define to 1 when performing static analysis.])
 
 +AC_DEFINE_UNQUOTED([isbase64],[gnulib_isbase64],[Hack to avoid symbol 
 clash])
 +AC_DEFINE_UNQUOTED([base64_encode],[gnulib_base64_encode],[Hack to avoid 
 symbol clash])
 +AC_DEFINE_UNQUOTED([base64_encode_alloc],[gnulib_base64_encode_alloc],[Hack 
 to avoid symbol clash])
 +
   AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \
docs/schemas/Makefile \
gnulib/lib/Makefile \
 
 Yes, that works for me. The secrets are working on Ubuntu 12.04.

Ok, I'll apply this, but with a 'libvirt_' prefix as Bruno requested

Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v4 00/12] Support hypervisor-threads-pin in vcpupin.

2012-08-02 Thread Gui jianfeng

Hey guys,

Any objection to this series?
If no, would someone help to commit this patchset?

Thanks,
Gui

On 2012/7/25 13:14, tangchen wrote:

Users can use vcpupin command to bind a vcpu thread to a specific physical cpu.
But besides vcpu threads, there are alse some other threads created by qemu
(known as hypervisor threads) that could not be explicitly bound to physical 
cpus.

The first 3 patches are from Wen Congyang, which implement Cgroup for differrent
hypervisors.

The other 10 patches implemented hypervisor threads binding, in two ways:
 1) Use sched_setaffinity() function;
 2) Use cpuset cgroup.

A new xml element is introduced, and vcpupin command is improved, see below.

1. Introduce new xml elements:
   cputune
   ..
   hypervisorpin cpuset='1'/
   /cputune

2. Improve vcpupin command to support hypervisor threads binding.

For example, vm1 has the following configuration:
   cputune
   vcpupin vcpu='1' cpuset='1'/
   vcpupin vcpu='0' cpuset='0'/
   hypervisorpin cpuset='1'/
   /cputune

   1) query all threads pining

  # vcpupin vm1
  VCPU: CPU Affinity
  --
 0: 0
 1: 1

  Hypervisor: CPU Affinity
  --
 *: 1

   2) query hypervisor threads pining only

  # vcpupin vm1 --hypervisor
  Hypervisor: CPU Affinity
  --
 *: 1

   3) change hypervisor threads pining

  # vcpupin vm1 --hypervisor 0-1

  # vcpupin vm1 --hypervisor
  Hypervisor: CPU Affinity
  --
 *: 0-1

  # taskset -p 397
  pid 397's current affinity mask: 3


Note: If users want to pin a vcpu thread to pcpu, --vcpu option could no longer 
be omitted.


Tang Chen (9):
   Enable cpuset cgroup and synchronous vcpupin info to cgroup.
   Support hypervisorpin xml parse.
   Introduce qemuSetupCgroupHypervisorPin and synchronize hypervisorpin
 info to cgroup.
   Add qemuProcessSetHypervisorAffinites and set hypervisor threads
 affinities
   Introduce virDomainHypervisorPinAdd and virDomainHypervisorPinDel
 functions
   Introduce virDomainPinHypervisorFlags and
 virDomainGetHypervisorPinInfo functions.
   Introduce qemudDomainPinHypervisorFlags and
 qemudDomainGetHypervisorPinInfo in qemu driver.
   Introduce remoteDomainPinHypervisorFlags and
 remoteDomainGetHypervisorPinInfo functions in remote driver.
   Improve vcpupin to support hypervisorpin dynically.

Wen Congyang (3):
   Introduce the function virCgroupForHypervisor
   Introduce the function virCgroupMoveTask
   create a new cgroup and move all hypervisor threads to the new cgroup

  daemon/remote.c |  103 +
  docs/schemas/domaincommon.rng   |7 +
  include/libvirt/libvirt.h.in|   10 +
  src/conf/domain_conf.c  |  169 +-
  src/conf/domain_conf.h  |7 +
  src/driver.h|   13 +-
  src/libvirt.c   |  147 +
  src/libvirt_private.syms|7 +
  src/libvirt_public.syms |2 +
  src/qemu/qemu_cgroup.c  |  151 -
  src/qemu/qemu_cgroup.h  |5 +
  src/qemu/qemu_driver.c  |  267 ++-
  src/qemu/qemu_process.c |   60 -
  src/remote/remote_driver.c  |  102 +
  src/remote/remote_protocol.x|   23 +-
  src/remote_protocol-structs |   24 ++
  src/util/cgroup.c   |  188 +++-
  src/util/cgroup.h   |   15 ++
  tests/qemuxml2argvdata/qemuxml2argv-cputune.xml |1 +
  tests/vcpupin   |6 +-
  tools/virsh.c   |  147 -
  tools/virsh.pod |   16 +-
  22 files changed, 1393 insertions(+), 77 deletions(-)




--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 2/2] build: Rename security manager library

2012-08-02 Thread Jiri Denemark
Security manager is not a dynamically loadable driver. Let's avoid the
confusion by renaming libvirt_driver_security library as
libvirt_security_manager.
---
 src/Makefile.am | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 2b09141..d74497d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1159,22 +1159,22 @@ libvirt_driver_nwfilter_la_SOURCES = 
$(NWFILTER_DRIVER_SOURCES)
 endif
 
 
-libvirt_driver_security_la_SOURCES = $(SECURITY_DRIVER_SOURCES)
-noinst_LTLIBRARIES += libvirt_driver_security.la
-libvirt_la_BUILT_LIBADD += libvirt_driver_security.la
-libvirt_driver_security_la_CFLAGS = \
+libvirt_security_manager_la_SOURCES = $(SECURITY_DRIVER_SOURCES)
+noinst_LTLIBRARIES += libvirt_security_manager.la
+libvirt_la_BUILT_LIBADD += libvirt_security_manager.la
+libvirt_security_manager_la_CFLAGS = \
-I$(top_srcdir)/src/conf $(AM_CFLAGS)
-libvirt_driver_security_la_LDFLAGS = $(AM_LDFLAGS)
-libvirt_driver_security_la_LIBADD =
+libvirt_security_manager_la_LDFLAGS = $(AM_LDFLAGS)
+libvirt_security_manager_la_LIBADD =
 if WITH_SECDRIVER_SELINUX
-libvirt_driver_security_la_SOURCES += $(SECURITY_DRIVER_SELINUX_SOURCES)
-libvirt_driver_security_la_CFLAGS += $(SELINUX_CFLAGS)
-libvirt_driver_security_la_LIBADD += $(SELINUX_LIBS)
+libvirt_security_manager_la_SOURCES += $(SECURITY_DRIVER_SELINUX_SOURCES)
+libvirt_security_manager_la_CFLAGS += $(SELINUX_CFLAGS)
+libvirt_security_manager_la_LIBADD += $(SELINUX_LIBS)
 endif
 if WITH_SECDRIVER_APPARMOR
-libvirt_driver_security_la_SOURCES += $(SECURITY_DRIVER_APPARMOR_SOURCES)
-libvirt_driver_security_la_CFLAGS += $(APPARMOR_CFLAGS)
-libvirt_driver_security_la_LIBADD += $(APPARMOR_LIBS)
+libvirt_security_manager_la_SOURCES += $(SECURITY_DRIVER_APPARMOR_SOURCES)
+libvirt_security_manager_la_CFLAGS += $(APPARMOR_CFLAGS)
+libvirt_security_manager_la_LIBADD += $(APPARMOR_LIBS)
 endif
 
 # Add all conditional sources just in case...
@@ -1611,7 +1611,7 @@ libvirt_lxc_LDADD =   \
$(NUMACTL_LIBS) \
libvirt-net-rpc-server.la \
libvirt-net-rpc.la \
-   libvirt_driver_security.la \
+   libvirt_security_manager.la \
libvirt_conf.la \
libvirt_util.la \
../gnulib/lib/libgnu.la
-- 
1.7.11.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/2] build: Link security manager into libvirt.so

2012-08-02 Thread Jiri Denemark
Security manager is not a dynamically loadable driver, it's a common
infrastructure similar to util, conf, cpu, etc. used by individual
drivers. Such code is allowed to be linked into libvirt.so.

This reverts commit ec5b7bd2ecbf40ceff5b2d4fc00d5cfdfba966a4 and most of
aae5cfb69948fddef556f8f5b9f80a444f9c6125.

This patch is supposed to fix virdrivermoduletest failures for qemu and
lxc drivers as well as libvirtd's ability to load qemu and lxc drivers.
---
 daemon/Makefile.am   |  1 -
 src/Makefile.am  |  3 +--
 src/libvirt_private.syms | 31 +++
 tests/Makefile.am|  5 ++---
 4 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index b8ecbef..928aeaf 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -164,7 +164,6 @@ endif
 if WITH_NWFILTER
 libvirtd_LDADD += ../src/libvirt_driver_nwfilter.la
 endif
-libvirtd_LDADD += ../src/libvirt_driver_security.la
 endif
 
 libvirtd_LDADD += ../src/libvirt.la
diff --git a/src/Makefile.am b/src/Makefile.am
index 6f8838b..2b09141 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1161,8 +1161,7 @@ endif
 
 libvirt_driver_security_la_SOURCES = $(SECURITY_DRIVER_SOURCES)
 noinst_LTLIBRARIES += libvirt_driver_security.la
-# Stateful, so linked to daemon instead
-#libvirt_la_BUILT_LIBADD += libvirt_driver_security.la
+libvirt_la_BUILT_LIBADD += libvirt_driver_security.la
 libvirt_driver_security_la_CFLAGS = \
-I$(top_srcdir)/src/conf $(AM_CFLAGS)
 libvirt_driver_security_la_LDFLAGS = $(AM_LDFLAGS)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 97f3b14..71341a2 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -962,6 +962,37 @@ virSecretUsageTypeTypeFromString;
 virSecretUsageTypeTypeToString;
 
 
+# security_driver.h
+virSecurityDriverLookup;
+
+
+# security_manager.h
+virSecurityManagerClearSocketLabel;
+virSecurityManagerFree;
+virSecurityManagerGenLabel;
+virSecurityManagerGetDOI;
+virSecurityManagerGetModel;
+virSecurityManagerGetProcessLabel;
+virSecurityManagerNew;
+virSecurityManagerNewStack;
+virSecurityManagerNewDAC;
+virSecurityManagerReleaseLabel;
+virSecurityManagerReserveLabel;
+virSecurityManagerRestoreImageLabel;
+virSecurityManagerRestoreAllLabel;
+virSecurityManagerRestoreHostdevLabel;
+virSecurityManagerRestoreSavedStateLabel;
+virSecurityManagerSetAllLabel;
+virSecurityManagerSetDaemonSocketLabel;
+virSecurityManagerSetImageFDLabel;
+virSecurityManagerSetImageLabel;
+virSecurityManagerSetHostdevLabel;
+virSecurityManagerSetProcessLabel;
+virSecurityManagerSetSavedStateLabel;
+virSecurityManagerSetSocketLabel;
+virSecurityManagerVerify;
+virSecurityManagerGetMountOptions;
+
 # sexpr.h
 sexpr_append;
 sexpr_cons;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b931cea..a466480 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -294,8 +294,7 @@ endif
 
 if WITH_QEMU
 
-qemu_LDADDS = ../src/libvirt_driver_qemu_impl.la \
-  ../src/libvirt_driver_security.la
+qemu_LDADDS = ../src/libvirt_driver_qemu_impl.la
 if WITH_NETWORK
 qemu_LDADDS += ../src/libvirt_driver_network_impl.la
 endif
@@ -520,7 +519,7 @@ virauthconfigtest_LDADD = $(LDADDS)
 
 seclabeltest_SOURCES = \
seclabeltest.c
-seclabeltest_LDADD = $(LDADDS) ../src/libvirt_driver_security.la
+seclabeltest_LDADD = $(LDADDS)
 
 virbuftest_SOURCES = \
virbuftest.c testutils.h testutils.c
-- 
1.7.11.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] daemon: Portable auto-detection of driver module directory

2012-08-02 Thread Jiri Denemark
When running libvirtd from a build directory on a system with unmodified
libtool, libvirtd's binary is not renamed as lt-libvirtd. Check for
/daemon/.libs/libvirtd in addition to lt-libvirtd.
---
 daemon/libvirtd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index ffbe067..a316427 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -972,7 +972,8 @@ int main(int argc, char **argv) {
 virLogSetFromEnv();
 
 #ifdef WITH_DRIVER_MODULES
-if (strstr(argv[0], lt-libvirtd)) {
+if (strstr(argv[0], lt-libvirtd) ||
+strstr(argv[0], /daemon/.libs/libvirtd)) {
 char *tmp = strrchr(argv[0], '/');
 if (!tmp) {
 fprintf(stderr, _(%s: cannot identify driver directory\n), 
argv[0]);
-- 
1.7.11.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 2/2] build: Rename security manager library

2012-08-02 Thread Daniel P. Berrange
On Thu, Aug 02, 2012 at 03:47:11PM +0200, Jiri Denemark wrote:
 Security manager is not a dynamically loadable driver. Let's avoid the
 confusion by renaming libvirt_driver_security library as
 libvirt_security_manager.
 ---
  src/Makefile.am | 26 +-
  1 file changed, 13 insertions(+), 13 deletions(-)
 
 diff --git a/src/Makefile.am b/src/Makefile.am
 index 2b09141..d74497d 100644
 --- a/src/Makefile.am
 +++ b/src/Makefile.am
 @@ -1159,22 +1159,22 @@ libvirt_driver_nwfilter_la_SOURCES = 
 $(NWFILTER_DRIVER_SOURCES)
  endif
  
  
 -libvirt_driver_security_la_SOURCES = $(SECURITY_DRIVER_SOURCES)
 -noinst_LTLIBRARIES += libvirt_driver_security.la
 -libvirt_la_BUILT_LIBADD += libvirt_driver_security.la
 -libvirt_driver_security_la_CFLAGS = \
 +libvirt_security_manager_la_SOURCES = $(SECURITY_DRIVER_SOURCES)
 +noinst_LTLIBRARIES += libvirt_security_manager.la
 +libvirt_la_BUILT_LIBADD += libvirt_security_manager.la
 +libvirt_security_manager_la_CFLAGS = \
   -I$(top_srcdir)/src/conf $(AM_CFLAGS)
 -libvirt_driver_security_la_LDFLAGS = $(AM_LDFLAGS)
 -libvirt_driver_security_la_LIBADD =
 +libvirt_security_manager_la_LDFLAGS = $(AM_LDFLAGS)
 +libvirt_security_manager_la_LIBADD =
  if WITH_SECDRIVER_SELINUX
 -libvirt_driver_security_la_SOURCES += $(SECURITY_DRIVER_SELINUX_SOURCES)
 -libvirt_driver_security_la_CFLAGS += $(SELINUX_CFLAGS)
 -libvirt_driver_security_la_LIBADD += $(SELINUX_LIBS)
 +libvirt_security_manager_la_SOURCES += $(SECURITY_DRIVER_SELINUX_SOURCES)
 +libvirt_security_manager_la_CFLAGS += $(SELINUX_CFLAGS)
 +libvirt_security_manager_la_LIBADD += $(SELINUX_LIBS)
  endif
  if WITH_SECDRIVER_APPARMOR
 -libvirt_driver_security_la_SOURCES += $(SECURITY_DRIVER_APPARMOR_SOURCES)
 -libvirt_driver_security_la_CFLAGS += $(APPARMOR_CFLAGS)
 -libvirt_driver_security_la_LIBADD += $(APPARMOR_LIBS)
 +libvirt_security_manager_la_SOURCES += $(SECURITY_DRIVER_APPARMOR_SOURCES)
 +libvirt_security_manager_la_CFLAGS += $(APPARMOR_CFLAGS)
 +libvirt_security_manager_la_LIBADD += $(APPARMOR_LIBS)
  endif
  
  # Add all conditional sources just in case...
 @@ -1611,7 +1611,7 @@ libvirt_lxc_LDADD = \
   $(NUMACTL_LIBS) \
   libvirt-net-rpc-server.la \
   libvirt-net-rpc.la \
 - libvirt_driver_security.la \
 + libvirt_security_manager.la \
   libvirt_conf.la \
   libvirt_util.la \
   ../gnulib/lib/libgnu.la

ACK


Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 1/2] build: Link security manager into libvirt.so

2012-08-02 Thread Daniel P. Berrange
On Thu, Aug 02, 2012 at 03:47:10PM +0200, Jiri Denemark wrote:
 Security manager is not a dynamically loadable driver, it's a common
 infrastructure similar to util, conf, cpu, etc. used by individual
 drivers. Such code is allowed to be linked into libvirt.so.
 
 This reverts commit ec5b7bd2ecbf40ceff5b2d4fc00d5cfdfba966a4 and most of
 aae5cfb69948fddef556f8f5b9f80a444f9c6125.
 
 This patch is supposed to fix virdrivermoduletest failures for qemu and
 lxc drivers as well as libvirtd's ability to load qemu and lxc drivers.
 ---
  daemon/Makefile.am   |  1 -
  src/Makefile.am  |  3 +--
  src/libvirt_private.syms | 31 +++
  tests/Makefile.am|  5 ++---
  4 files changed, 34 insertions(+), 6 deletions(-)

ACK

Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] daemon: Portable auto-detection of driver module directory

2012-08-02 Thread Daniel P. Berrange
On Thu, Aug 02, 2012 at 03:47:32PM +0200, Jiri Denemark wrote:
 When running libvirtd from a build directory on a system with unmodified
 libtool, libvirtd's binary is not renamed as lt-libvirtd. Check for
 /daemon/.libs/libvirtd in addition to lt-libvirtd.
 ---
  daemon/libvirtd.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
 index ffbe067..a316427 100644
 --- a/daemon/libvirtd.c
 +++ b/daemon/libvirtd.c
 @@ -972,7 +972,8 @@ int main(int argc, char **argv) {
  virLogSetFromEnv();
  
  #ifdef WITH_DRIVER_MODULES
 -if (strstr(argv[0], lt-libvirtd)) {
 +if (strstr(argv[0], lt-libvirtd) ||
 +strstr(argv[0], /daemon/.libs/libvirtd)) {
  char *tmp = strrchr(argv[0], '/');
  if (!tmp) {
  fprintf(stderr, _(%s: cannot identify driver directory\n), 
 argv[0]);
ACK

Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 1/2] build: Link security manager into libvirt.so

2012-08-02 Thread Jiri Denemark
On Thu, Aug 02, 2012 at 15:02:04 +0100, Daniel P. Berrange wrote:
 On Thu, Aug 02, 2012 at 03:47:10PM +0200, Jiri Denemark wrote:
  Security manager is not a dynamically loadable driver, it's a common
  infrastructure similar to util, conf, cpu, etc. used by individual
  drivers. Such code is allowed to be linked into libvirt.so.
  
  This reverts commit ec5b7bd2ecbf40ceff5b2d4fc00d5cfdfba966a4 and most of
  aae5cfb69948fddef556f8f5b9f80a444f9c6125.
  
  This patch is supposed to fix virdrivermoduletest failures for qemu and
  lxc drivers as well as libvirtd's ability to load qemu and lxc drivers.
  ---
   daemon/Makefile.am   |  1 -
   src/Makefile.am  |  3 +--
   src/libvirt_private.syms | 31 +++
   tests/Makefile.am|  5 ++---
   4 files changed, 34 insertions(+), 6 deletions(-)
 
 ACK

Thanks, pushed.

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] daemon: Portable auto-detection of driver module directory

2012-08-02 Thread Jiri Denemark
On Thu, Aug 02, 2012 at 15:02:59 +0100, Daniel P. Berrange wrote:
 On Thu, Aug 02, 2012 at 03:47:32PM +0200, Jiri Denemark wrote:
  When running libvirtd from a build directory on a system with unmodified
  libtool, libvirtd's binary is not renamed as lt-libvirtd. Check for
  /daemon/.libs/libvirtd in addition to lt-libvirtd.
  ---
   daemon/libvirtd.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
  
  diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
  index ffbe067..a316427 100644
  --- a/daemon/libvirtd.c
  +++ b/daemon/libvirtd.c
  @@ -972,7 +972,8 @@ int main(int argc, char **argv) {
   virLogSetFromEnv();
   
   #ifdef WITH_DRIVER_MODULES
  -if (strstr(argv[0], lt-libvirtd)) {
  +if (strstr(argv[0], lt-libvirtd) ||
  +strstr(argv[0], /daemon/.libs/libvirtd)) {
   char *tmp = strrchr(argv[0], '/');
   if (!tmp) {
   fprintf(stderr, _(%s: cannot identify driver directory\n), 
  argv[0]);
 ACK

Thanks, push.

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] qemu: Fix typo in qemuDomainModifyDeviceFlags

2012-08-02 Thread Michal Privoznik
One of our latest commits fbe87126 introduced this nasty typo:
func(vmdef, ...); where func() dereference vmdef-ncontrollers,
and vmdef was initialized to NULL. This leaves us with unconditional
immediate segfault. It should be vm-def instead.
---

Despite this could qualify to be pushed under trivial rule, I'd feel more
comfortable with an ACK.

 src/qemu/qemu_driver.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b3f946c..270e4dd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5833,7 +5833,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char 
*xml,
 }
 
 if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
-if (virDomainDefCompatibleDevice(vmdef, dev)  0)
+if (virDomainDefCompatibleDevice(vm-def, dev)  0)
 goto endjob;
 
 /* Make a copy for updated domain. */
-- 
1.7.8.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: Fix typo in qemuDomainModifyDeviceFlags

2012-08-02 Thread Peter Krempa

On 08/02/12 16:30, Michal Privoznik wrote:

One of our latest commits fbe87126 introduced this nasty typo:
func(vmdef, ...); where func() dereference vmdef-ncontrollers,
and vmdef was initialized to NULL. This leaves us with unconditional
immediate segfault. It should be vm-def instead.
---

Despite this could qualify to be pushed under trivial rule, I'd feel more
comfortable with an ACK.

  src/qemu/qemu_driver.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)



Gah, mea culpa. ACK.

Peter

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: Fix typo in qemuDomainModifyDeviceFlags

2012-08-02 Thread Michal Privoznik
On 02.08.2012 16:42, Peter Krempa wrote:
 On 08/02/12 16:30, Michal Privoznik wrote:
 One of our latest commits fbe87126 introduced this nasty typo:
 func(vmdef, ...); where func() dereference vmdef-ncontrollers,
 and vmdef was initialized to NULL. This leaves us with unconditional
 immediate segfault. It should be vm-def instead.
 ---

 Despite this could qualify to be pushed under trivial rule, I'd feel more
 comfortable with an ACK.

   src/qemu/qemu_driver.c |2 +-
   1 files changed, 1 insertions(+), 1 deletions(-)

 
 Gah, mea culpa. ACK.
 
 Peter

Thanks, pushed.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] block: Set cdrom device read only flag

2012-08-02 Thread Kevin Shanahan
On Thu, Aug 02, 2012 at 02:49:52PM +0930, Kevin Shanahan wrote:
 On Thu, Aug 02, 2012 at 11:46:13AM +0930, Kevin Shanahan wrote:
  On Thu, Aug 02, 2012 at 11:02:42AM +0930, Kevin Shanahan wrote:
   Set the block driver read_only flag for cdrom devices so that
   qmp_change_blockdev does not attempt to open cdrom files in read-write
   mode when changing media.
  
  Hrm, this fixes my simple test case using the kvm monitor directly but
  changing media via libvirt still has the same issue (fails for RO
  files, succeeds for writable files).
  
  $ virsh attach-disk --type cdrom --mode readonly test1 
  /srv/kvm/iso/ubuntu-12.04-server-amd64.iso hdc
  error: Failed to attach disk
  error: internal error unable to execute QEMU command 'change': Could not 
  open '/srv/kvm/iso/ubuntu-12.04-server-amd64.iso'
  
  I'll keep looking into it.
 
 In the libvirt case, it seems libvirt is failing to add media=cdrom to
 the commandline, so in this case qemu is defaulting to media=disk and
 my proposed fix has no effect. Diving into libvirt now to see why no
 media=disk is getting added...
 
 Common test case has this xml (generated by virt-install):
 
 disk type='block' device='cdrom'
   driver name='qemu' type='raw'/
   target dev='hdc' bus='ide'/
   readonly/
   alias name='ide0-1-0'/
   address type='drive' controller='0' bus='1' target='0' unit='0'/
 /disk

Ok, looks like libvirt is intentionally leaving media=cdrom off the
command line in the case that -device ide-cd,... is
supported. Presumably by specifying the device this way, qemu is
supposed to work out that the media type is cdrom automatically (but
it doesn't, it defaults to disk).

Libvirt wants to use:

qemu-kvm ... \
 -drive if=none,id=drive-ide0-1-0,readonly=on,format=raw \
 -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 ...

If I hack qemu/qemu_command.c::qemuBuildDriveStr() to ignore the check
for QEMU_CAPS_IDE_CD and always add media=cdrom, then (with my qemu as
well patch) qemu will open cdrom media files read-only.

There's probably a neater way to just get qemu to set the media type
if -device ide-cd,... is used, but I haven't worked it out yet.

Anyway, apologies for the rambling conversation with myself on your
lists. Hope this is helpful in some way.

Cheers,
Kevin.


--- libvirt-0.9.13.orig/src/qemu/qemu_command.c.orig2012-08-02 
16:45:25.0 +0930
+++ libvirt-0.9.13.orig/src/qemu/qemu_command.c 2012-08-02 16:46:11.0 
+0930
@@ -2082,7 +2082,7 @@
 if (!qemuCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD))
 virBufferAddLit(opt, ,media=cdrom);
 } else if (disk-bus == VIR_DOMAIN_DISK_BUS_IDE) {
-if (!qemuCapsGet(qemuCaps, QEMU_CAPS_IDE_CD))
+//if (!qemuCapsGet(qemuCaps, QEMU_CAPS_IDE_CD))
 virBufferAddLit(opt, ,media=cdrom);
 } else {
 virBufferAddLit(opt, ,media=cdrom);

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] block: Set cdrom device read only flag

2012-08-02 Thread Kevin Shanahan
On Thu, Aug 02, 2012 at 11:46:13AM +0930, Kevin Shanahan wrote:
 On Thu, Aug 02, 2012 at 11:02:42AM +0930, Kevin Shanahan wrote:
  Set the block driver read_only flag for cdrom devices so that
  qmp_change_blockdev does not attempt to open cdrom files in read-write
  mode when changing media.
 
 Hrm, this fixes my simple test case using the kvm monitor directly but
 changing media via libvirt still has the same issue (fails for RO
 files, succeeds for writable files).
 
 $ virsh attach-disk --type cdrom --mode readonly test1 
 /srv/kvm/iso/ubuntu-12.04-server-amd64.iso hdc
 error: Failed to attach disk
 error: internal error unable to execute QEMU command 'change': Could not open 
 '/srv/kvm/iso/ubuntu-12.04-server-amd64.iso'
 
 I'll keep looking into it.

In the libvirt case, it seems libvirt is failing to add media=cdrom to
the commandline, so in this case qemu is defaulting to media=disk and
my proposed fix has no effect. Diving into libvirt now to see why no
media=disk is getting added...

Common test case has this xml (generated by virt-install):

disk type='block' device='cdrom'
  driver name='qemu' type='raw'/
  target dev='hdc' bus='ide'/
  readonly/
  alias name='ide0-1-0'/
  address type='drive' controller='0' bus='1' target='0' unit='0'/
/disk

 Cheers,
 Kevin.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v5 6/6] block: Enable qemu_open/close to work with fd sets

2012-08-02 Thread Corey Bryant



On 07/25/2012 11:57 PM, Corey Bryant wrote:



On 07/25/2012 03:43 PM, Eric Blake wrote:

On 07/23/2012 07:08 AM, Corey Bryant wrote:

When qemu_open is passed a filename of the /dev/fdset/nnn
format (where nnn is the fdset ID), an fd with matching access
mode flags will be searched for within the specified monitor
fd set.  If the fd is found, a dup of the fd will be returned
from qemu_open.

Each fd set has a reference count.  The purpose of the reference
count is to determine if an fd set contains file descriptors that
have open dup() references that have not yet been closed.  It is
incremented on qemu_open and decremented on qemu_close.  It is
not until the refcount is zero that file desriptors in an fd set
can be closed.  If an fd set has dup() references open, then we
must keep the other fds in the fd set open in case a reopen
of the file occurs that requires an fd with a different access
mode.




+++ b/monitor.c
@@ -2551,6 +2551,91 @@ static void monitor_fdsets_set_in_use(Monitor
*mon, bool in_use)
  }
  }

+void monitor_fdset_increment_refcount(Monitor *mon, int64_t fdset_id)
+{
+mon_fdset_t *mon_fdset;
+
+if (!mon) {
+return;
+}


Am I reading this code right by stating that 'if there is no monitor, we
don't increment the refcount'?  How does a monitor reattach affect
things?  Or am I missing something fundamental about the cases when
'mon==NULL' will exist?



Yes you're reading this correctly.

I'm pretty sure that mon will only be NULL if QEMU is started without a
monitor.

If QEMU has a monitor, and libvirt disconnects it's connection to the
qemu monitor, then I believe mon will remain non-NULL.


I've verified this to be true and everything is working as expected.

If libvirt's connection to the monitor fd is closed, mon will remain 
non-NULL and the refcount will still be incremented/decremented on 
qemu_open()/qemu_close().  When libvirt reconnects, any fdsets that 
haven't been cleaned up will still be available.  query-fdsets can be 
used to determine what's available.


--
Regards,
Corey

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] build: commit to 0.10.0 release naming

2012-08-02 Thread Daniel Veillard
On Thu, Aug 02, 2012 at 06:54:37PM +0800, Daniel Veillard wrote:
 On Wed, Aug 01, 2012 at 01:27:09PM -0600, Eric Blake wrote:
  On 08/01/2012 01:18 PM, Guido Günther wrote:
   On Wed, Aug 01, 2012 at 11:00:35AM -0600, Eric Blake wrote:
   With 0.10.0-rc0 out the door, we are committed to the next version
   number.
  
   * src/libvirt_public.syms (LIBVIRT_0.9.14): Rename...
   (LIBVIRT_0.10.0): ...to this.
   * docs/formatdomain.html.in: Fix fallout.
   * src/openvz/openvz_driver.c (openvzDriver): Likewise.
   * src/remote/remote_driver.c (remote_driver): Likewise.
   ---
  
   I almost pushed this under the trivial rule, but realized that
   anyone that builds an app against rc0 will be binary incompatible
   with the .so post-patch.  Are we okay declaring that rc0 is
   unsupported so the ABI break is okay, or do I need to respin
   the .syms portion of this patch to keep the LIBVIRT_0.9.14
   label even though we had no 0.9.14 release?
   
   If rc1 won't be too far in the future (so it can be pushed into distros)
   just changing the symbol names is probably good enough.
  
  DV said that rc1 might be as much as 3 weeks away.  If distros want to
  push rc0 out the door, and we decide to go with this patch as-is, then
  distros should backport this patch on top of rc0 for minimal pain.
 
   yeah rc0 is not a release candidate, it's a snapshot, it's basically
 unsupported. It may not have compliled (it didn't in some configurations)
 it is a completely arbitrary upstream commit, like one of the
ftp://libvirt.org/libvirt/libvirt-git-snapshot.tar.gz
 
 So your patch looks fine to me, i re-did it on my own too, so ACK

  BTW I pushed yours since you gave more commit comments :-)

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [glib PATCH V3] Add bindings for virDomainSnapshotCreateXML()

2012-08-02 Thread Jovanka Gulicoska
---
 libvirt-gobject/libvirt-gobject-domain.c | 52 
 libvirt-gobject/libvirt-gobject-domain.h |  7 +
 libvirt-gobject/libvirt-gobject.sym  |  2 ++
 3 files changed, 61 insertions(+)

diff --git a/libvirt-gobject/libvirt-gobject-domain.c 
b/libvirt-gobject/libvirt-gobject-domain.c
index 861f713..31aa61a 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -1273,3 +1273,55 @@ GList *gvir_domain_get_devices(GVirDomain *domain,
 
 return g_list_reverse (ret);
 }
+
+/**
+ * gvir_domain_create_snapshot:
+ * @dom: the domain
+ * @custom_conf: (allow-none): configuration of snapshot or NULL
+ * @flags: the flags
+ * @err: (allow-none):Place-holder for error or NULL
+ *
+ * Returns: (transfer full): snapshot of domain. The returned object should be
+ * unreffed when no longer needed
+ */
+GVirDomainSnapshot *
+gvir_domain_create_snapshot(GVirDomain *dom,
+ GVirConfigDomainSnapshot *custom_conf,
+ guint flags,
+ GError **err)
+{
+GVirDomainPrivate *priv;
+virDomainSnapshot *snapshot;
+GVirDomainSnapshot *dom_snapshot;
+gchar *custom_xml = NULL;
+
+g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
+g_return_val_if_fail(err == NULL || *err == NULL, NULL);
+
+priv = dom-priv;
+
+if (custom_conf != NULL)
+custom_xml = 
gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(custom_conf));
+
+if (!(snapshot = virDomainSnapshotCreateXML(priv-handle,
+custom_xml,
+flags))) {
+const gchar *domain_name = NULL;
+domain_name = gvir_domain_get_name(dom);
+
+gvir_set_error(err, GVIR_DOMAIN_ERROR,
+   0,
+  Unable to create snapshot of %s, domain_name);
+
+g_free(custom_xml);
+return NULL;
+}
+
+dom_snapshot = GVIR_DOMAIN_SNAPSHOT(g_object_new(GVIR_TYPE_DOMAIN_SNAPSHOT,
+ handle,
+ snapshot,
+ NULL));
+
+g_free(custom_xml);
+return dom_snapshot;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain.h 
b/libvirt-gobject/libvirt-gobject-domain.h
index c61a2f5..d10fa8d 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -31,6 +31,7 @@ G_BEGIN_DECLS
 
 #include libvirt-gobject/libvirt-gobject-stream.h
 #include libvirt/libvirt.h
+#include libvirt-gobject/libvirt-gobject-domain-snapshot.h
 
 #define GVIR_TYPE_DOMAIN(gvir_domain_get_type ())
 #define GVIR_DOMAIN(obj)(G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GVIR_TYPE_DOMAIN, GVirDomain))
@@ -247,6 +248,12 @@ gboolean gvir_domain_get_saved(GVirDomain *dom);
 GList *gvir_domain_get_devices(GVirDomain *domain,
GError **err);
 
+GVirDomainSnapshot *
+gvir_domain_create_snapshot(GVirDomain *dom,
+GVirConfigDomainSnapshot *custom_conf,
+guint flags,
+GError **err);
+
 G_END_DECLS
 
 #endif /* __LIBVIRT_GOBJECT_DOMAIN_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.sym 
b/libvirt-gobject/libvirt-gobject.sym
index 8f7bcef..5d15e7a 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -183,6 +183,8 @@ LIBVIRT_GOBJECT_0.1.1 {
   global:
gvir_domain_shutdown_flags_get_type;
gvir_domain_xml_flags_get_type;
+
+   gvir_domain_create_snapshot;
 } LIBVIRT_GOBJECT_0.0.9;
 
 #  define new API here using predicted next version number 
-- 
1.7.11.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Introduce an internal API for handling file based lockspaces

2012-08-02 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

The previously introduced virFile{Lock,Unlock} APIs provide a
way to acquire/release fcntl() locks on individual files. For
unknown reason though, the POSIX spec says that fcntl() locks
are released when *any* file handle refering to the same path
is closed. In the following sequence

  threadA: fd1 = open(foo)
  threadB: fd2 = open(foo)
  threadA: virFileLock(fd1)
  threadB: virFileLock(fd2)
  threadB: close(fd2)

you'd expect threadA to come out holding a lock on 'foo', and
indeed it does hold a lock for a very short time. Unfortunately
when threadB does close(fd2) this releases the lock associated
with fd1. For the current libvirt use case for virFileLock -
pidfiles - this doesn't matter since the lock is acquired
at startup while single threaded an never released until
exit.

To provide a more generally useful API though, it is neccessary
to introduce a slightly higher level abstraction, which is to
be referred to as a lockspace.  This is to be provided by
a virLockSpacePtr object in src/util/virlockspace.{c,h}. The
core idea is that the lockspace keeps track of what files are
already open+locked. This means that when a 2nd thread comes
along and tries to acquire a lock, it doesn't end up opening
and closing a new FD. The lockspace just checks the current
list of held locks and immediately returns VIR_ERR_RESOURCE_BUSY.

NB, the API as it stands is designed on the basis that the
files being locked are not being otherwise opened and used
by the application code. ie the files which are used to
maintain the locks are not the files associated with the
resources themselves. One approach to using this API is to
acquire locks based on a hash of the filepath.

eg to lock /var/lib/libvirt/images/foo.img the application
might do

   virLockSpacePtr lockspace = virLockSpaceNew(/var/lib/libvirt/imagelocks);
   lockname = md5sum(/var/lib/libvirt/images/foo.img)
   virLockSpaceAcquireLock(lockspace, lockname)

This patch is the basis for the soon to be re-submitted
patch series providing a virtlockd daemon
---
 .gitignore  |   1 +
 include/libvirt/virterror.h |   2 +
 src/Makefile.am |   1 +
 src/libvirt_private.syms|   9 +
 src/util/virlockspace.c | 419 
 src/util/virlockspace.h |  51 ++
 src/util/virterror.c|   9 +-
 tests/Makefile.am   |   7 +-
 tests/virlockspacetest.c| 311 
 9 files changed, 808 insertions(+), 2 deletions(-)
 create mode 100644 src/util/virlockspace.c
 create mode 100644 src/util/virlockspace.h
 create mode 100644 tests/virlockspacetest.c

diff --git a/.gitignore b/.gitignore
index 5ea281a..9e566c4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -157,6 +157,7 @@
 /tests/virdrivermoduletest
 /tests/virhashtest
 /tests/virkeyfiletest
+/tests/virlockspacetest
 /tests/virnet*test
 /tests/virshtest
 /tests/virtimetest
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index ad8e101..3e72cb7 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -110,6 +110,7 @@ typedef enum {
 VIR_FROM_AUTH = 46, /* Error from auth handling */
 VIR_FROM_DBUS = 47, /* Error from DBus */
 VIR_FROM_PARALLELS = 48,/* Error from Parallels */
+VIR_FROM_LOCKSPACE = 49,/* Error from lockspace */
 
 # ifdef VIR_ENUM_SENTINELS
 VIR_ERR_DOMAIN_LAST
@@ -277,6 +278,7 @@ typedef enum {
 VIR_ERR_MIGRATE_UNSAFE = 81,/* Migration is not safe */
 VIR_ERR_OVERFLOW = 82,  /* integer overflow */
 VIR_ERR_BLOCK_COPY_ACTIVE = 83, /* action prevented by block copy job 
*/
+VIR_ERR_RESOURCE_BUSY = 84, /* resource is already in use */
 } virErrorNumber;
 
 /**
diff --git a/src/Makefile.am b/src/Makefile.am
index b48ce65..527a2b8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -95,6 +95,7 @@ UTIL_SOURCES =
\
util/virkeycode.c util/virkeycode.h \
util/virkeyfile.c util/virkeyfile.h \
util/virkeymaps.h   \
+   util/virlockspace.c util/virlockspace.h \
util/virmacaddr.h util/virmacaddr.c \
util/virnetdev.h util/virnetdev.c   \
util/virnetdevbandwidth.h util/virnetdevbandwidth.c \
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index ac392fe..69f021d 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1248,6 +1248,15 @@ virKeyFileHasGroup;
 virKeyFileGetValueString;
 
 
+# virlockspace.h
+virLockSpaceNew;
+virLockSpaceFree;
+virLockSpaceCreateResource;
+virLockSpaceDeleteResource;
+virLockSpaceAcquireResource;
+virLockSpaceReleaseResource;
+
+
 # virmacaddr.h
 virMacAddrCmp;
 virMacAddrCmpRaw;
diff --git a/src/util/virlockspace.c 

[libvirt] [PATCH v2] Introduce an internal API for handling file based lockspaces

2012-08-02 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

The previously introduced virFile{Lock,Unlock} APIs provide a
way to acquire/release fcntl() locks on individual files. For
unknown reason though, the POSIX spec says that fcntl() locks
are released when *any* file handle refering to the same path
is closed. In the following sequence

  threadA: fd1 = open(foo)
  threadB: fd2 = open(foo)
  threadA: virFileLock(fd1)
  threadB: virFileLock(fd2)
  threadB: close(fd2)

you'd expect threadA to come out holding a lock on 'foo', and
indeed it does hold a lock for a very short time. Unfortunately
when threadB does close(fd2) this releases the lock associated
with fd1. For the current libvirt use case for virFileLock -
pidfiles - this doesn't matter since the lock is acquired
at startup while single threaded an never released until
exit.

To provide a more generally useful API though, it is neccessary
to introduce a slightly higher level abstraction, which is to
be referred to as a lockspace.  This is to be provided by
a virLockSpacePtr object in src/util/virlockspace.{c,h}. The
core idea is that the lockspace keeps track of what files are
already open+locked. This means that when a 2nd thread comes
along and tries to acquire a lock, it doesn't end up opening
and closing a new FD. The lockspace just checks the current
list of held locks and immediately returns VIR_ERR_RESOURCE_BUSY.

NB, the API as it stands is designed on the basis that the
files being locked are not being otherwise opened and used
by the application code. One approach to using this API is to
acquire locks based on a hash of the filepath.

eg to lock /var/lib/libvirt/images/foo.img the application
might do

   virLockSpacePtr lockspace = virLockSpaceNew(/var/lib/libvirt/imagelocks);
   lockname = md5sum(/var/lib/libvirt/images/foo.img)
   virLockSpaceAcquireLock(lockspace, lockname)

It is also possible to do locks directly on resources by
using a NULL lockspace directory and then using the file
path as the lock name eg

   virLockSpacePtr lockspace = virLockSpaceNew(NULL)
   virLockSpaceAcquireLock(lockspace, /var/lib/libvirt/images/foo.img)

This is only safe todo though if no other part of the proces
will be opening the files. This will be the case when this
code is used inside the soon-to-be-reposted virlockd daemon
---
 .gitignore  |   1 +
 include/libvirt/virterror.h |   2 +
 src/Makefile.am |   1 +
 src/libvirt_private.syms|   9 +
 src/util/virlockspace.c | 430 
 src/util/virlockspace.h |  51 ++
 src/util/virterror.c|   9 +-
 tests/Makefile.am   |   7 +-
 tests/virlockspacetest.c| 360 +
 9 files changed, 868 insertions(+), 2 deletions(-)
 create mode 100644 src/util/virlockspace.c
 create mode 100644 src/util/virlockspace.h
 create mode 100644 tests/virlockspacetest.c

diff --git a/.gitignore b/.gitignore
index 5ea281a..9e566c4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -157,6 +157,7 @@
 /tests/virdrivermoduletest
 /tests/virhashtest
 /tests/virkeyfiletest
+/tests/virlockspacetest
 /tests/virnet*test
 /tests/virshtest
 /tests/virtimetest
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index ad8e101..3e72cb7 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -110,6 +110,7 @@ typedef enum {
 VIR_FROM_AUTH = 46, /* Error from auth handling */
 VIR_FROM_DBUS = 47, /* Error from DBus */
 VIR_FROM_PARALLELS = 48,/* Error from Parallels */
+VIR_FROM_LOCKSPACE = 49,/* Error from lockspace */
 
 # ifdef VIR_ENUM_SENTINELS
 VIR_ERR_DOMAIN_LAST
@@ -277,6 +278,7 @@ typedef enum {
 VIR_ERR_MIGRATE_UNSAFE = 81,/* Migration is not safe */
 VIR_ERR_OVERFLOW = 82,  /* integer overflow */
 VIR_ERR_BLOCK_COPY_ACTIVE = 83, /* action prevented by block copy job 
*/
+VIR_ERR_RESOURCE_BUSY = 84, /* resource is already in use */
 } virErrorNumber;
 
 /**
diff --git a/src/Makefile.am b/src/Makefile.am
index b48ce65..527a2b8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -95,6 +95,7 @@ UTIL_SOURCES =
\
util/virkeycode.c util/virkeycode.h \
util/virkeyfile.c util/virkeyfile.h \
util/virkeymaps.h   \
+   util/virlockspace.c util/virlockspace.h \
util/virmacaddr.h util/virmacaddr.c \
util/virnetdev.h util/virnetdev.c   \
util/virnetdevbandwidth.h util/virnetdevbandwidth.c \
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index ac392fe..69f021d 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1248,6 +1248,15 @@ virKeyFileHasGroup;
 virKeyFileGetValueString;
 
 
+# virlockspace.h
+virLockSpaceNew;

Re: [libvirt] [PATCH] Introduce an internal API for handling file based lockspaces

2012-08-02 Thread Daniel P. Berrange
On Thu, Aug 02, 2012 at 05:20:52PM +0100, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com
 
 The previously introduced virFile{Lock,Unlock} APIs provide a
 way to acquire/release fcntl() locks on individual files. For
 unknown reason though, the POSIX spec says that fcntl() locks
 are released when *any* file handle refering to the same path
 is closed. In the following sequence
 
   threadA: fd1 = open(foo)
   threadB: fd2 = open(foo)
   threadA: virFileLock(fd1)
   threadB: virFileLock(fd2)
   threadB: close(fd2)
 
 you'd expect threadA to come out holding a lock on 'foo', and
 indeed it does hold a lock for a very short time. Unfortunately
 when threadB does close(fd2) this releases the lock associated
 with fd1. For the current libvirt use case for virFileLock -
 pidfiles - this doesn't matter since the lock is acquired
 at startup while single threaded an never released until
 exit.
 
 To provide a more generally useful API though, it is neccessary
 to introduce a slightly higher level abstraction, which is to
 be referred to as a lockspace.  This is to be provided by
 a virLockSpacePtr object in src/util/virlockspace.{c,h}. The
 core idea is that the lockspace keeps track of what files are
 already open+locked. This means that when a 2nd thread comes
 along and tries to acquire a lock, it doesn't end up opening
 and closing a new FD. The lockspace just checks the current
 list of held locks and immediately returns VIR_ERR_RESOURCE_BUSY.
 
 NB, the API as it stands is designed on the basis that the
 files being locked are not being otherwise opened and used
 by the application code. ie the files which are used to
 maintain the locks are not the files associated with the
 resources themselves. One approach to using this API is to
 acquire locks based on a hash of the filepath.
 
 eg to lock /var/lib/libvirt/images/foo.img the application
 might do
 
virLockSpacePtr lockspace = virLockSpaceNew(/var/lib/libvirt/imagelocks);
lockname = md5sum(/var/lib/libvirt/images/foo.img)
virLockSpaceAcquireLock(lockspace, lockname)
 
 This patch is the basis for the soon to be re-submitted
 patch series providing a virtlockd daemon

Sorry, ignore this patch. I forgot to commit some other
local changes to it before sending. See the new v2.

Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] virsh: Switch to close callback

2012-08-02 Thread Michal Privoznik
Since we've introduced close callbacks we can drop this SIGINT magic
(which doesn't work now neither) and fully utilize the new feature.
---
 tools/virsh.c |   45 -
 1 files changed, 16 insertions(+), 29 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 4670ee6..b95a008 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -568,31 +568,16 @@ static int disconnected = 0; /* we may have been 
disconnected */
 /*
  * vshCatchDisconnect:
  *
- * We get here when a SIGPIPE is being raised, we can't do much in the
- * handler, just save the fact it was raised
- */
-static void vshCatchDisconnect(int sig, siginfo_t *siginfo,
-   void *context ATTRIBUTE_UNUSED) {
-if (sig == SIGPIPE ||
-(SA_SIGINFO  siginfo-si_signo == SIGPIPE))
-disconnected++;
-}
-
-/*
- * vshSetupSignals:
- *
- * Catch SIGPIPE signals which may arise when disconnection
- * from libvirtd occurs
+ * We get here when the connection was closed.  We can't do much in the
+ * handler, just save the fact it was raised.
  */
 static void
-vshSetupSignals(void) {
-struct sigaction sig_action;
-
-sig_action.sa_sigaction = vshCatchDisconnect;
-sig_action.sa_flags = SA_SIGINFO;
-sigemptyset(sig_action.sa_mask);
-
-sigaction(SIGPIPE, sig_action, NULL);
+vshCatchDisconnect(virConnectPtr conn ATTRIBUTE_UNUSED,
+   int reason,
+   void *opaque ATTRIBUTE_UNUSED)
+{
+if (reason != VIR_CONNECT_CLOSE_REASON_CLIENT)
+disconnected++;
 }
 
 /*
@@ -614,10 +599,15 @@ vshReconnect(vshControl *ctl)
 ctl-conn = virConnectOpenAuth(ctl-name,
virConnectAuthPtrDefault,
ctl-readonly ? VIR_CONNECT_RO : 0);
-if (!ctl-conn)
+if (!ctl-conn) {
 vshError(ctl, %s, _(Failed to reconnect to the hypervisor));
-else if (connected)
-vshError(ctl, %s, _(Reconnected to the hypervisor));
+} else {
+if (virConnectRegisterCloseCallback(ctl-conn, vshCatchDisconnect,
+NULL, NULL)  0)
+vshError(ctl, %s, _(Unable to register disconnect callback));
+if (connected)
+vshError(ctl, %s, _(Reconnected to the hypervisor));
+}
 disconnected = 0;
 ctl-useGetInfo = false;
 ctl-useSnapshotOld = false;
@@ -2458,9 +2448,6 @@ vshInit(vshControl *ctl)
 /* set up the library error handler */
 virSetErrorFunc(NULL, virshErrorHandler);
 
-/* set up the signals handlers to catch disconnections */
-vshSetupSignals();
-
 if (virEventRegisterDefaultImpl()  0)
 return false;
 
-- 
1.7.8.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH v3 4/7] qemu: Implement virDomainInterfacesAddresses

2012-08-02 Thread Michal Privoznik
---
 include/libvirt/libvirt.h.in |1 +
 src/qemu/qemu_driver.c   |   76 ++
 tools/virsh-domain-monitor.c |   19 ++
 tools/virsh.pod  |   19 +-
 4 files changed, 106 insertions(+), 9 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index d5d131a..7f25a0a 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1742,6 +1742,7 @@ struct _virDomainInterface {
 
 typedef enum {
 VIR_DOMAIN_INTERFACE_ADDRS_DEFAULT  = 0, /* hypervisor choice */
+VIR_DOMAIN_INTERFACE_ADDRS_GUEST_AGENT  = (1  0), /* use guest agent */
 } virDomainInterfacesAddressesFlags;
 
 int virDomainInterfacesAddresses (virDomainPtr dom,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 270e4dd..f90ab41 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13173,6 +13173,81 @@ qemuListAllDomains(virConnectPtr conn,
 return ret;
 }
 
+static int
+qemuDomainInterfacesAddresses(virDomainPtr dom,
+  virDomainInterfacePtr *ifaces,
+  unsigned int flags)
+{
+struct qemud_driver *driver = dom-conn-privateData;
+qemuDomainObjPrivatePtr priv = NULL;
+virDomainObjPtr vm = NULL;
+int ret = -1;
+
+virCheckFlags(VIR_DOMAIN_INTERFACE_ADDRS_DEFAULT |
+  VIR_DOMAIN_INTERFACE_ADDRS_GUEST_AGENT, -1);
+
+if (!ifaces) {
+virReportError(VIR_ERR_INVALID_ARG, %s,
+   _(ifaces cannot be NULL));
+return -1;
+}
+
+qemuDriverLock(driver);
+vm = virDomainFindByUUID(driver-domains, dom-uuid);
+qemuDriverUnlock(driver);
+
+if (!vm) {
+char uuidstr[VIR_UUID_STRING_BUFLEN];
+virUUIDFormat(dom-uuid, uuidstr);
+virReportError(VIR_ERR_NO_DOMAIN,
+   _(no domain with matching uuid '%s'), uuidstr);
+goto cleanup;
+}
+
+if (!virDomainObjIsActive(vm)) {
+virReportError(VIR_ERR_OPERATION_INVALID, %s,
+   _(domain is not running));
+goto cleanup;
+}
+
+priv = vm-privateData;
+
+if (priv-agentError) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(QEMU guest agent is not 
+ available due to an error));
+goto cleanup;
+}
+
+if (!priv-agent) {
+virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, %s,
+   _(QEMU guest agent is not configured));
+goto cleanup;
+}
+
+if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY)  0)
+goto cleanup;
+
+if (!virDomainObjIsActive(vm)) {
+virReportError(VIR_ERR_OPERATION_INVALID, %s,
+   _(domain is not running));
+goto endjob;
+}
+
+qemuDomainObjEnterAgent(driver, vm);
+ret = qemuAgentGetInterfaces(priv-agent, ifaces);
+qemuDomainObjExitAgent(driver, vm);
+
+endjob:
+if (qemuDomainObjEndJob(driver, vm) == 0)
+vm = NULL;
+
+cleanup:
+if (vm)
+virDomainObjUnlock(vm);
+return ret;
+}
+
 static virDriver qemuDriver = {
 .no = VIR_DRV_QEMU,
 .name = QEMU_DRIVER_NAME,
@@ -13338,6 +13413,7 @@ static virDriver qemuDriver = {
 .domainPMSuspendForDuration = qemuDomainPMSuspendForDuration, /* 0.9.11 */
 .domainPMWakeup = qemuDomainPMWakeup, /* 0.9.11 */
 .domainGetCPUStats = qemuDomainGetCPUStats, /* 0.9.11 */
+.domainInterfacesAddresses = qemuDomainInterfacesAddresses, /* 0.10.0 */
 };
 
 
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index fb6fe23..b4a5088 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -1694,6 +1694,7 @@ static const vshCmdInfo info_domifaddr[] = {
 static const vshCmdOptDef opts_domifaddr[] = {
 {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
 {interface, VSH_OT_DATA, VSH_OFLAG_NONE, N_(network interface name)},
+{mode, VSH_OT_STRING, VSH_OFLAG_NONE, N_(querying mode: 
default|agent)},
 {NULL, 0, 0, NULL}
 };
 
@@ -1703,6 +1704,7 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
 virDomainPtr dom = NULL;
 const char *device = NULL;
 virDomainInterfacePtr ifaces = NULL;
+const char *mode = NULL;
 int i, j, ifaces_count = 0;
 unsigned int flags = 0;
 bool ret = false;
@@ -1717,6 +1719,23 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
 goto cleanup;
 }
 
+if (vshCommandOptString(cmd, mode, mode)  0) {
+vshError(ctl, %s, _(Invalid type));
+return false;
+}
+
+if (mode) {
+if (STREQ(mode, default)) {
+flags |= VIR_DOMAIN_INTERFACE_ADDRS_DEFAULT;
+} else if (STREQ(mode, agent)) {
+flags |= VIR_DOMAIN_INTERFACE_ADDRS_GUEST_AGENT;
+} else {
+vshError(ctl, _(Unknown mode %s value, 
+expecting 'default' or 'agent'), mode);
+

[libvirt] [PATCH v3 0/7] Introduce API for dumping domain IP addresses

2012-08-02 Thread Michal Privoznik
This feature has been requested for a very long time. However,
we had to wait for guest agent to obtain reliable results as
user might create totally different structure of interfaces than
seen from outside (e.g. bonding, virtual interfaces, etc.).
That's the main reason why sniffing for domain traffic can
return bogus results. Fortunately, qemu guest agent implement
requested part for a while so nothing holds us back anymore.

To make matters worse, guest OS can assign whatever name to
an interface and changing MAC inside guest isn't propagated
to the host which in the end see original one.

Therefore, finding correlation between interface within guest
and the host side end is left as exercise for mgmt applications.

This API is called virDomainInterfacesAddresses (okay, maybe
too many plurals) and returns a dynamically allocated array
of virDomainInterface struct. We agreed on this in previous versions.

Michal Privoznik (7):
  Introduce virDomainInterfacesAddresses API
  virsh: Expose virDomainInterfacesAddresses
  qemu_agent: Implement 'guest-network-get-interfaces' command handling
  qemu: Implement virDomainInterfacesAddresses
  remote: Implement virDomainInterfacesAddresses
  python: Expose virDomainInterfacesAddresses
  python: create example for dumping domain IP addresses

 daemon/remote.c |  124 +++
 examples/python/Makefile.am |2 +-
 examples/python/README  |1 +
 examples/python/domipaddrs.py   |   50 +
 include/libvirt/libvirt.h.in|   36 +
 python/generator.py |1 +
 python/libvirt-override-api.xml |6 ++
 python/libvirt-override.c   |  115 
 src/driver.h|5 +
 src/libvirt.c   |   98 
 src/libvirt_public.syms |1 +
 src/qemu/qemu_agent.c   |  156 +++
 src/qemu/qemu_agent.h   |3 +
 src/qemu/qemu_driver.c  |   76 +++
 src/remote/remote_driver.c  |   88 ++
 src/remote/remote_protocol.x|   24 ++-
 src/remote_protocol-structs |   24 ++
 tools/virsh-domain-monitor.c|  112 
 tools/virsh.pod |   11 +++
 19 files changed, 931 insertions(+), 2 deletions(-)
 create mode 100644 examples/python/domipaddrs.py

-- 
1.7.8.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH v3 2/7] virsh: Expose virDomainInterfacesAddresses

2012-08-02 Thread Michal Privoznik
---
 tools/virsh-domain-monitor.c |   93 ++
 tools/virsh.pod  |   10 +
 2 files changed, 103 insertions(+), 0 deletions(-)

diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 151a8d0..fb6fe23 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -1683,6 +1683,98 @@ cleanup:
 }
 #undef FILTER
 
+/* domifaddr command
+ */
+static const vshCmdInfo info_domifaddr[] = {
+{help, N_(get network interfaces addresses for a domain)},
+{desc, N_(Get network interfaces addresses for a running domain)},
+{NULL, NULL}
+};
+
+static const vshCmdOptDef opts_domifaddr[] = {
+{domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
+{interface, VSH_OT_DATA, VSH_OFLAG_NONE, N_(network interface name)},
+{NULL, 0, 0, NULL}
+};
+
+static bool
+cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
+{
+virDomainPtr dom = NULL;
+const char *device = NULL;
+virDomainInterfacePtr ifaces = NULL;
+int i, j, ifaces_count = 0;
+unsigned int flags = 0;
+bool ret = false;
+
+if (!vshConnectionUsability(ctl, ctl-conn))
+return false;
+
+if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+return false;
+
+if (vshCommandOptString(cmd, interface, device)  0) {
+goto cleanup;
+}
+
+ifaces_count = virDomainInterfacesAddresses(dom, ifaces, flags);
+if (ifaces_count  0) {
+vshError(ctl, _(Failed to query for interfaces addresses));
+goto cleanup;
+}
+
+vshPrintExtra(ctl,  %-10s %-17s%s\n%s\n,
+  _(Name), _(HW address), _(IP address),
+  ---);
+
+for (i = 0; i  ifaces_count; i++) {
+virDomainInterfacePtr iface = (ifaces[i]);
+virBuffer buf = VIR_BUFFER_INITIALIZER;
+const char *hwaddr = ;
+const char *ip_addr_str = NULL;
+
+if (device  STRNEQ(device, iface-name))
+continue;
+
+if (iface-hwaddr)
+hwaddr = iface-hwaddr;
+
+for (j = 0; j  iface-ip_addrs_count; j++) {
+if (j)
+virBufferAddChar(buf, ' ');
+virBufferAsprintf(buf, %s/%d,
+  iface-ip_addrs[j].addr,
+  iface-ip_addrs[j].prefix);
+}
+
+ip_addr_str = virBufferContentAndReset(buf);
+
+if (!ip_addr_str)
+ip_addr_str = ;
+
+vshPrintExtra(ctl,  %-10s %-17s%s\n,
+ iface-name, hwaddr, ip_addr_str);
+
+virBufferFreeAndReset(buf);
+}
+
+ret = true;
+
+cleanup:
+for (i = 0; i  ifaces_count; i++) {
+VIR_FREE(ifaces[i].name);
+VIR_FREE(ifaces[i].hwaddr);
+for (j = 0; j  ifaces[i].ip_addrs_count; j++)
+VIR_FREE(ifaces[i].ip_addrs[j].addr);
+VIR_FREE(ifaces[i].ip_addrs);
+}
+VIR_FREE(ifaces);
+
+if (dom)
+virDomainFree(dom);
+return ret;
+}
+
 static const vshCmdDef domMonitoringCmds[] = {
 {domblkerror, cmdDomBlkError, opts_domblkerror, info_domblkerror, 0},
 {domblkinfo, cmdDomblkinfo, opts_domblkinfo, info_domblkinfo, 0},
@@ -1690,6 +1782,7 @@ static const vshCmdDef domMonitoringCmds[] = {
 {domblkstat, cmdDomblkstat, opts_domblkstat, info_domblkstat, 0},
 {domcontrol, cmdDomControl, opts_domcontrol, info_domcontrol, 0},
 {domif-getlink, cmdDomIfGetLink, opts_domif_getlink, info_domif_getlink, 
0},
+{domifaddr, cmdDomIfAddr, opts_domifaddr, info_domifaddr, 0},
 {domiflist, cmdDomiflist, opts_domiflist, info_domiflist, 0},
 {domifstat, cmdDomIfstat, opts_domifstat, info_domifstat, 0},
 {dominfo, cmdDominfo, opts_dominfo, info_dominfo, 0},
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 35613c4..daf5889 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -605,6 +605,16 @@ BExplanation of fields (fields appear in the folowing 
order):
   flush_total_times - total time flush operations took (ns)
 -- other fields provided by hypervisor --
 
+=item Bdomifaddr Idomain [Iinterface-device]
+
+Get a list of interfaces of domain among with their IP and hardware
+addresses, or if Iinterface-device is specified limit output just
+for that one interface. Note, that interface name can be driver
+dependent meaning it can be name within guest OS or the name you would
+see in domain XML. Moreover, the whole command may require a guest
+agent to be configured for the queried domain under some drivers,
+notably qemu.
+
 =item Bdomifstat Idomain Iinterface-device
 
 Get network interface stats for a running domain.
-- 
1.7.8.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH v3 6/7] python: Expose virDomainInterfacesAddresses

2012-08-02 Thread Michal Privoznik
---
 python/libvirt-override-api.xml |6 ++
 python/libvirt-override.c   |  115 +++
 2 files changed, 121 insertions(+), 0 deletions(-)

diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml
index 67ef36e..eb08151 100644
--- a/python/libvirt-override-api.xml
+++ b/python/libvirt-override-api.xml
@@ -487,5 +487,11 @@
   arg name='domain' type='virDomainPtr' info='a domain object'/
   arg name='flags' type='unsigned int' info='unused, always pass 0'/
 /function
+function name='virDomainInterfacesAddresses' file='python'
+  inforeturns array of IP addresses for all domain interfaces/info
+  arg name='dom' type='virDomainPtr' info='pointer to the domain'/
+  arg name='flags' type='unsigned int' info='extra flags; not used yet, 
so callers should always pass 0'/
+  return type='virDomainInterfacePtr' info=dictionary of domain 
interfaces among with their HW and IP addresses/
+/function
   /symbols
 /api
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 8b41dff..7081626 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -3982,6 +3982,120 @@ cleanup:
 return py_retval;
 }
 
+static PyObject *
+libvirt_virDomainInterfacesAddresses(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args)
+{
+PyObject *py_retval = VIR_PY_NONE;
+virDomainPtr domain;
+PyObject *pyobj_domain;
+unsigned int flags;
+virDomainInterfacePtr ifaces = NULL;
+int ifaces_count = 0;
+int i, j;
+bool full_free = true;
+
+if (!PyArg_ParseTuple(args, (char *) Oi:virDomainInterfacePtr,
+  pyobj_domain, flags))
+return NULL;
+
+domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+LIBVIRT_BEGIN_ALLOW_THREADS;
+ifaces_count = virDomainInterfacesAddresses(domain, ifaces, flags);
+LIBVIRT_END_ALLOW_THREADS;
+if (ifaces_count  0)
+goto cleanup;
+
+if (!(py_retval = PyDict_New()))
+goto no_memory;
+
+for (i = 0; i  ifaces_count; i++) {
+virDomainInterfacePtr iface = (ifaces[i]);
+PyObject *py_ip_addrs = NULL;
+PyObject *py_iface = NULL;
+
+if (!(py_iface = PyDict_New()))
+goto no_memory;
+
+if (iface-ip_addrs_count) {
+if (!(py_ip_addrs = PyList_New(iface-ip_addrs_count))) {
+{ Py_DECREF(py_iface); }
+goto no_memory;
+}
+} else {
+py_ip_addrs = VIR_PY_NONE;
+}
+
+for (j = 0; j  iface-ip_addrs_count; j++) {
+virDomainIPAddressPtr ip_addr = (iface-ip_addrs[j]);
+PyObject *py_addr = PyDict_New();
+const char *type;
+
+if (!py_addr) {
+{ Py_DECREF(py_iface); }
+{ Py_DECREF(py_ip_addrs); }
+goto no_memory;
+}
+
+switch (ip_addr-type) {
+case VIR_IP_ADDR_TYPE_IPV4:
+type = ipv4;
+break;
+case VIR_IP_ADDR_TYPE_IPV6:
+type = ipv6;
+break;
+default:
+type = unknown;
+break;
+}
+
+PyDict_SetItem(py_addr, libvirt_constcharPtrWrap(addr),
+   PyString_FromString(ip_addr-addr));
+PyDict_SetItem(py_addr, libvirt_constcharPtrWrap(prefix),
+   libvirt_intWrap(ip_addr-prefix));
+PyDict_SetItem(py_addr, libvirt_constcharPtrWrap(type),
+   PyString_FromString(type));
+
+PyList_SetItem(py_ip_addrs, j, py_addr);
+}
+
+PyDict_SetItem(py_iface, libvirt_constcharPtrWrap(ip_addrs),
+   py_ip_addrs);
+PyDict_SetItem(py_iface, libvirt_constcharPtrWrap(hwaddr),
+   libvirt_charPtrWrap(iface-hwaddr));
+
+PyDict_SetItem(py_retval, libvirt_charPtrWrap(iface-name),
+   py_iface);
+}
+
+full_free = false;
+
+cleanup:
+for (i = 0; i  ifaces_count; i++) {
+/* We don't want to free values we've just
+ * shared with python variables unless
+ * there was an error and hence we are
+ * retyrning PY_NONE or equivalent */
+if (full_free) {
+VIR_FREE(ifaces[i].name);
+VIR_FREE(ifaces[i].hwaddr);
+for (j = 0; j  ifaces[i].ip_addrs_count; j++)
+VIR_FREE(ifaces[i].ip_addrs[j].addr);
+}
+VIR_FREE(ifaces[i].ip_addrs);
+}
+VIR_FREE(ifaces);
+
+return py_retval;
+
+no_memory:
+Py_XDECREF(py_retval);
+py_retval = PyErr_NoMemory();
+goto cleanup;
+}
+
+
 /***
  * Helper functions to avoid importing modules
  * for every callback
@@ -5915,6 +6029,7 @@ static PyMethodDef libvirtMethods[] = {
 {(char *) virDomainBlockPeek, 

[libvirt] [PATCH v3 5/7] remote: Implement virDomainInterfacesAddresses

2012-08-02 Thread Michal Privoznik
---
 daemon/remote.c  |  124 ++
 src/remote/remote_driver.c   |   88 ++
 src/remote/remote_protocol.x |   24 -
 src/remote_protocol-structs  |   24 
 4 files changed, 259 insertions(+), 1 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index d25717c..4b44a5a 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4112,3 +4112,127 @@ no_memory:
 virReportOOMError();
 return -1;
 }
+
+static int
+remoteSerializeDomainInterfacePtr(virDomainInterfacePtr ifaces,
+  int ifaces_count,
+  remote_domain_interfaces_addresses_ret *ret)
+{
+int i, j;
+
+ret-ifaces.ifaces_len = ifaces_count;
+
+if (ifaces_count 
+VIR_ALLOC_N(ret-ifaces.ifaces_val, ifaces_count)  0)
+goto no_memory;
+
+for (i = 0; i  ifaces_count; i++) {
+virDomainInterfacePtr iface = (ifaces[i]);
+remote_domain_interface *iface_ret = (ret-ifaces.ifaces_val[i]);
+
+if (!(iface_ret-name = strdup(iface-name)))
+goto no_memory;
+
+if (iface-hwaddr) {
+char **hwaddr_p = NULL;
+if (VIR_ALLOC(hwaddr_p)  0)
+goto no_memory;
+*hwaddr_p = strdup(iface-hwaddr);
+if (!hwaddr_p)
+goto no_memory;
+
+iface_ret-hwaddr = hwaddr_p;
+}
+
+iface_ret-ip_addrs.ip_addrs_len = iface-ip_addrs_count;
+
+if (iface-ip_addrs_count 
+VIR_ALLOC_N(iface_ret-ip_addrs.ip_addrs_val,
+iface-ip_addrs_count)  0)
+goto no_memory;
+
+for (j = 0; j  iface-ip_addrs_count; j++) {
+virDomainIPAddressPtr ip_addr = (iface-ip_addrs[j]);
+remote_domain_ip_addr *ip_addr_ret =
+(iface_ret-ip_addrs.ip_addrs_val[j]);
+
+if (!(ip_addr_ret-addr = strdup(ip_addr-addr)))
+goto no_memory;
+
+ip_addr_ret-prefix = ip_addr-prefix;
+ip_addr_ret-type = ip_addr-type;
+}
+}
+
+return 0;
+
+no_memory:
+if (ret-ifaces.ifaces_val) {
+for (i = 0; i  ifaces_count; i++) {
+remote_domain_interface *iface_ret = (ret-ifaces.ifaces_val[i]);
+VIR_FREE(iface_ret-name);
+VIR_FREE(iface_ret-hwaddr);
+for (j = 0; j  iface_ret-ip_addrs.ip_addrs_len; j++) {
+remote_domain_ip_addr *ip_addr =
+(iface_ret-ip_addrs.ip_addrs_val[j]);
+VIR_FREE(ip_addr-addr);
+}
+}
+VIR_FREE(ret-ifaces.ifaces_val);
+}
+virReportOOMError();
+return -1;
+}
+
+static int
+remoteDispatchDomainInterfacesAddresses(
+virNetServerPtr server ATTRIBUTE_UNUSED,
+virNetServerClientPtr client,
+virNetMessagePtr msg ATTRIBUTE_UNUSED,
+virNetMessageErrorPtr rerr,
+remote_domain_interfaces_addresses_args *args,
+remote_domain_interfaces_addresses_ret *ret)
+{
+int rv = -1;
+virDomainPtr dom = NULL;
+virDomainInterfacePtr ifaces = NULL;
+int ifaces_count = 0;
+struct daemonClientPrivate *priv =
+virNetServerClientGetPrivateData(client);
+
+if (!priv-conn) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s, _(connection not open));
+goto cleanup;
+}
+
+if (!(dom = get_nonnull_domain(priv-conn, args-dom)))
+goto cleanup;
+
+ifaces_count = virDomainInterfacesAddresses(dom, ifaces, args-flags);
+if (ifaces_count  0)
+goto cleanup;
+
+if (remoteSerializeDomainInterfacePtr(ifaces, ifaces_count, ret)  0)
+goto cleanup;
+
+rv = 0;
+
+cleanup:
+if (rv  0)
+virNetMessageSaveError(rerr);
+if (dom)
+virDomainFree(dom);
+if (ifaces) {
+int i, j;
+
+for (i = 0; i  ifaces_count; i++) {
+VIR_FREE(ifaces[i].name);
+VIR_FREE(ifaces[i].hwaddr);
+for (j = 0; j  ifaces[i].ip_addrs_count; j++)
+VIR_FREE(ifaces[i].ip_addrs[j].addr);
+VIR_FREE(ifaces[i].ip_addrs);
+}
+VIR_FREE(ifaces);
+}
+return rv;
+}
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index b9e2127..4306789 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5060,6 +5060,93 @@ done:
 return rv;
 }
 
+static int
+remoteDomainInterfacesAddresses(virDomainPtr dom,
+virDomainInterfacePtr *ifaces,
+unsigned int flags)
+{
+int rv = -1;
+remote_domain_interfaces_addresses_args args;
+remote_domain_interfaces_addresses_ret ret;
+struct private_data *priv = dom-conn-privateData;
+int i, j;
+
+memset(ret, 0, sizeof(ret));
+args.flags = flags;
+make_nonnull_domain(args.dom, dom);
+
+remoteDriverLock(priv);
+
+if (call(dom-conn, priv, 0, 

[libvirt] [PATCH v3 1/7] Introduce virDomainInterfacesAddresses API

2012-08-02 Thread Michal Privoznik
This API returns dynamically allocated array of IP addresses for
all domain interfaces.
---
 include/libvirt/libvirt.h.in |   35 +++
 python/generator.py  |1 +
 src/driver.h |5 ++
 src/libvirt.c|   98 ++
 src/libvirt_public.syms  |1 +
 5 files changed, 140 insertions(+), 0 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index d21d029..d5d131a 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1713,6 +1713,41 @@ int virDomainGetInterfaceParameters 
(virDomainPtr dom,
 virTypedParameterPtr 
params,
 int *nparams, unsigned 
int flags);
 
+typedef enum {
+VIR_IP_ADDR_TYPE_IPV4,
+VIR_IP_ADDR_TYPE_IPV6,
+
+#ifdef VIR_ENUM_SENTINELS
+VIR_IP_ADDR_TYPE_LAST
+#endif
+} virIPAddrType;
+
+
+typedef struct _virDomainInterfaceIPAddress virDomainIPAddress;
+typedef virDomainIPAddress *virDomainIPAddressPtr;
+struct _virDomainInterfaceIPAddress {
+int type;   /* virIPAddrType */
+char *addr; /* IP address */
+int prefix; /* IP address prefix */
+};
+
+typedef struct _virDomainInterface virDomainInterface;
+typedef virDomainInterface *virDomainInterfacePtr;
+struct _virDomainInterface {
+char *name; /* interface name */
+char *hwaddr;   /* hardware address */
+unsigned int ip_addrs_count;/* number of items in @ip_addr */
+virDomainIPAddressPtr ip_addrs; /* array of IP addresses */
+};
+
+typedef enum {
+VIR_DOMAIN_INTERFACE_ADDRS_DEFAULT  = 0, /* hypervisor choice */
+} virDomainInterfacesAddressesFlags;
+
+int virDomainInterfacesAddresses (virDomainPtr dom,
+  virDomainInterfacePtr *ifaces,
+  unsigned int flags);
+
 /* Management of domain block devices */
 
 int virDomainBlockPeek (virDomainPtr dom,
diff --git a/python/generator.py b/python/generator.py
index 6559ece..7c1a51d 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -427,6 +427,7 @@ skip_impl = (
 'virDomainGetDiskErrors',
 'virConnectUnregisterCloseCallback',
 'virConnectRegisterCloseCallback',
+'virDomainInterfacesAddresses',
 )
 
 qemu_skip_impl = (
diff --git a/src/driver.h b/src/driver.h
index aab9766..4460dc9 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -404,6 +404,10 @@ typedef int
   const char *device,
   virTypedParameterPtr params,
   int *nparams, unsigned int flags);
+typedef int
+(*virDrvDomainInterfacesAddresses)   (virDomainPtr dom,
+  virDomainInterfacePtr *ifaces,
+  unsigned int flags);
 
 typedef int
 (*virDrvDomainMemoryStats)
@@ -1012,6 +1016,7 @@ struct _virDriver {
 virDrvDomainSnapshotListNames   domainSnapshotListNames;
 virDrvDomainListAllSnapshotsdomainListAllSnapshots;
 virDrvDomainSnapshotNumChildren domainSnapshotNumChildren;
+virDrvDomainInterfacesAddresses domainInterfacesAddresses;
 virDrvDomainSnapshotListChildrenNames domainSnapshotListChildrenNames;
 virDrvDomainSnapshotListAllChildren domainSnapshotListAllChildren;
 virDrvDomainSnapshotLookupByNamedomainSnapshotLookupByName;
diff --git a/src/libvirt.c b/src/libvirt.c
index 3c4bf8c..7cb1c58 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -7380,6 +7380,104 @@ error:
 }
 
 /**
+ * virDomainInterfacesAddresses:
+ * @dom: domain object
+ * @ifaces: array of @dom interfaces
+ * @flags: bitwise-OR of virDomainInterfacesAddressesFlags
+ *
+ * Return an array of interfaces presented in given domain among with their IP
+ * and HW addresses. Note, that single interface can have multiple or even none
+ * IP address.
+ *
+ * This API dynamically allocates the virDomainInterfacePtr struct based on how
+ * much interfaces domain @dom has, usually there's 1:1 correlation. The count
+ * of elements allocated is then returned.
+ *
+ * Note that for some combination of @flags and hypervisors a configured guest
+ * agent is needed for successful return from this API.  Moreover, if guest
+ * agent is used then the interface name is the one seen by guest OS. To match
+ * such interface with the  one from @dom XML use HW address or IP range.
+ *
+ * @ifaces-name is never NULL, @ifaces-hwaddr might be NULL,
+ *
+ * The caller *must* free @ifaces when no longer needed.  Usual use case looks
+ * like this:
+ *
+ * virDomainInterfacePtr ifaces = NULL;
+ * int ifaces_count = 0;
+ * int i, j;
+ * virDomainPtr dom = ... obtain a domain here ...;
+ *
+ * ifaces_count = 

[libvirt] [PATCH v3 3/7] qemu_agent: Implement 'guest-network-get-interfaces' command handling

2012-08-02 Thread Michal Privoznik
This command returns an array of all guest interfaces among
with their IP and HW addresses.
---
 src/qemu/qemu_agent.c |  156 +
 src/qemu/qemu_agent.h |3 +
 2 files changed, 159 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 14bf11b..2ada3fe 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1410,3 +1410,159 @@ qemuAgentSuspend(qemuAgentPtr mon,
 virJSONValueFree(reply);
 return ret;
 }
+
+int
+qemuAgentGetInterfaces(qemuAgentPtr mon,
+   virDomainInterfacePtr *ifaces)
+{
+int ret = -1;
+int i, j, size = -1;
+virJSONValuePtr cmd;
+virJSONValuePtr reply = NULL;
+virJSONValuePtr ret_array = NULL;
+
+cmd = qemuAgentMakeCommand(guest-network-get-interfaces, NULL);
+
+if (!cmd)
+return -1;
+
+if (qemuAgentCommand(mon, cmd, reply)  0 ||
+qemuAgentCheckError(cmd, reply)  0)
+goto cleanup;
+
+if (!(ret_array = virJSONValueObjectGet(reply, return))) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(qemu agent didn't provide 'return' field));
+goto cleanup;
+}
+
+if ((size = virJSONValueArraySize(ret_array))  0) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(qemu agent didn't return an array of interfaces));
+goto cleanup;
+}
+
+if (size  VIR_ALLOC_N(*ifaces, size)  0) {
+virReportOOMError();
+goto cleanup;
+}
+
+for (i = 0; i  size; i++) {
+virJSONValuePtr tmp_iface = virJSONValueArrayGet(ret_array, i);
+virJSONValuePtr ip_addr_arr = NULL;
+const char *name, *hwaddr;
+int ip_addr_arr_size;
+
+/* Shouldn't happen but doesn't hurt to check neither */
+if (!tmp_iface) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(something has went really wrong));
+goto cleanup;
+}
+
+/* interface name is required to be presented */
+name = virJSONValueObjectGetString(tmp_iface, name);
+if (!name) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(qemu agent didn't provide 'name' field));
+goto cleanup;
+}
+
+if (!((*ifaces)[i].name = strdup(name))) {
+virReportOOMError();
+goto cleanup;
+}
+
+/* hwaddr might be omitted */
+hwaddr = virJSONValueObjectGetString(tmp_iface, hardware-address);
+if (hwaddr  !((*ifaces)[i].hwaddr = strdup(hwaddr))) {
+virReportOOMError();
+goto cleanup;
+}
+
+/* as well as IP address which - moreover -
+ * can be presented multiple times */
+ip_addr_arr = virJSONValueObjectGet(tmp_iface, ip-addresses);
+if (!ip_addr_arr)
+continue;
+
+if ((ip_addr_arr_size = virJSONValueArraySize(ip_addr_arr))  0) {
+/* Mmm, empty 'ip-address'? */
+continue;
+}
+
+(*ifaces)[i].ip_addrs_count = (unsigned int) ip_addr_arr_size;
+
+if (ip_addr_arr_size 
+VIR_ALLOC_N((*ifaces)[i].ip_addrs, ip_addr_arr_size)  0) {
+virReportOOMError();
+goto cleanup;
+}
+
+for (j = 0; j  ip_addr_arr_size; j++) {
+virJSONValuePtr ip_addr_obj = virJSONValueArrayGet(ip_addr_arr, j);
+virDomainIPAddressPtr ip_addr = (*ifaces)[i].ip_addrs[j];
+const char *type, *addr;
+
+/* Shouldn't happen but doesn't hurt to check neither */
+if (!ip_addr_obj) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(something has went really wrong));
+goto cleanup;
+}
+
+type = virJSONValueObjectGetString(ip_addr_obj, ip-address-type);
+if (!type) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(qemu agent didn't provide 'ip-address-type'
+  field for interface '%s'), name);
+goto cleanup;
+} else if (STREQ(type, ipv4)) {
+ip_addr-type = VIR_IP_ADDR_TYPE_IPV4;
+} else if (STREQ(type, ipv6)) {
+ip_addr-type = VIR_IP_ADDR_TYPE_IPV6;
+} else {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(unknown ip address type '%s'),
+   type);
+goto cleanup;
+}
+
+addr = virJSONValueObjectGetString(ip_addr_obj, ip-address);
+if (!addr) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(qemu agent didn't provide 'ip-address'
+  field for interface '%s'), name);
+goto cleanup;
+}
+if 

[libvirt] [PATCH v3 7/7] python: create example for dumping domain IP addresses

2012-08-02 Thread Michal Privoznik
---
 examples/python/Makefile.am   |2 +-
 examples/python/README|1 +
 examples/python/domipaddrs.py |   50 +
 3 files changed, 52 insertions(+), 1 deletions(-)
 create mode 100644 examples/python/domipaddrs.py

diff --git a/examples/python/Makefile.am b/examples/python/Makefile.am
index b04d126..b51f729 100644
--- a/examples/python/Makefile.am
+++ b/examples/python/Makefile.am
@@ -4,4 +4,4 @@
 EXTRA_DIST=\
README  \
consolecallback.py  \
-   dominfo.py domrestore.py domsave.py domstart.py esxlist.py
+   dominfo.py domrestore.py domsave.py domstart.py esxlist.py domipaddrs.py
diff --git a/examples/python/README b/examples/python/README
index f4db76c..d895740 100644
--- a/examples/python/README
+++ b/examples/python/README
@@ -10,6 +10,7 @@ domsave.py  - save all running domU's into a directory
 domrestore.py - restore domU's from their saved files in a directory
 esxlist.py  - list active domains of an VMware ESX host and print some info.
   also demonstrates how to use the libvirt.openAuth() method
+domipaddrs.py - print domain interfaces among with their HW and IP addresses
 
 The XML files in this directory are examples of the XML format that libvirt
 expects, and will have to be adapted for your setup. They are only needed
diff --git a/examples/python/domipaddrs.py b/examples/python/domipaddrs.py
new file mode 100644
index 000..74c0716
--- /dev/null
+++ b/examples/python/domipaddrs.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+# domipaddrds - print IP addresses for running domain
+
+import libvirt
+import sys
+
+def usage():
+print Usage: %s [URI] DOMAIN % sys.argv[0]
+print Print IP addresses assigned to domain interfaces
+
+uri = None
+name = None
+args = len(sys.argv)
+
+if args == 2:
+name = sys.argv[1]
+elif args == 3:
+uri = sys.argv[1]
+name = sys.argv[2]
+else:
+usage()
+sys.exit(2)
+
+conn = libvirt.openReadOnly(uri)
+if conn == None:
+print Unable to open connection to libvirt
+sys.exit(1)
+
+try:
+dom = conn.lookupByName(name)
+except libvirt.libvirtError:
+print Domain %s not found % name
+sys.exit(0)
+
+ifaces = dom.interfacesAddresses(0)
+if (ifaces == None):
+print Failed to get domain interfaces
+sys.exit(0)
+
+print  {0:10} {1:17}{2}.format(Interface, HW address, IP Address)
+
+for (name, val) in ifaces.iteritems():
+print  {0:10} {1:17}.format(name, val['hwaddr']),
+
+if (val['ip_addrs']  None):
+print   ,
+for addr in val['ip_addrs']:
+print {0}/{1} .format(addr['addr'], addr['prefix']),
+
+print
-- 
1.7.8.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] virsh: Switch to close callback

2012-08-02 Thread Jiri Denemark
On Thu, Aug 02, 2012 at 19:22:17 +0200, Michal Privoznik wrote:
 Since we've introduced close callbacks we can drop this SIGINT magic
 (which doesn't work now neither) and fully utilize the new feature.
 ---
  tools/virsh.c |   45 -
  1 files changed, 16 insertions(+), 29 deletions(-)

ACK

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] virsh: Switch to close callback

2012-08-02 Thread Michal Privoznik
On 02.08.2012 20:25, Jiri Denemark wrote:
 On Thu, Aug 02, 2012 at 19:22:17 +0200, Michal Privoznik wrote:
 Since we've introduced close callbacks we can drop this SIGINT magic
 (which doesn't work now neither) and fully utilize the new feature.
 ---
  tools/virsh.c |   45 -
  1 files changed, 16 insertions(+), 29 deletions(-)
 
 ACK
 
 Jirka
 

Thanks, pushed.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] Proposal to add iSCSI support to esx storage driver

2012-08-02 Thread Ata Bohra
Hi All, 
 
I just want to go over the design that I am working on to incorporate iSCSI 
support to libvirt ESX storage driver. The highlights are:
 
Current Implementation
At present esx_storage_driver supports only VMFS type datastore and does not 
provide much leeway to enhance or add other supported storage pools such as 
iSCSI. 
 
Proposal
My proposal is:
1. Split the current code such as esx_storage_driver becomes more like a 
facade; this driver will use backend drivers to perform the request task 
(such as: esx_storage_backend_iscsi and esx_storage_backend_vmfs)
2. Based on the pool type (lookup can determine storage pool type), the base 
driver then invoke the appropriate backend driver routine to get the job done. 
3. Backend driver shall implement same routines exposed by esx_storage_driver 
if needed, but the implementation will be pertinent to its specific type. 
 
The main intention is get early feedback w.r.t the above proposed design. This 
allows me to make changes quickly before I present the code for review and am 
sure will help expedite the overall review process as well. 
 
Thanks for your suggestions/comments.
 
Thanks  Regards,
Ata E Husain Bohra
Appendex:
Sample code to implement .lookupByName for esx storage driver
 
static virStoragePoolPtr
esxStoragePoolLookupByName(virConnectPtr conn, const char *name)
{
esxPrivate *priv = conn-storagePrivateData;
virStoragePoolPtr pool = NULL;
int i = 0; 
if (esxVI_EnsureSession(priv-primary)  0) { 
return NULL;
}
for (i = 0; i  MAX_BACKEND_DRIVER; ++i) {
pool = backendDrv[i]-poolLookupByName(conn, name);   // backendDrv are 
pointer to backend storage drivers.
if (pool != NULL) {
break;
}
}
return pool;
}
 
  --
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCHv2] build: add stubs so mdns code can be unconditionally compiled

2012-08-02 Thread Eric Blake
On 08/02/2012 04:11 AM, Daniel P. Berrange wrote:
 On Wed, Aug 01, 2012 at 05:52:42PM -0600, Eric Blake wrote:
 The recent changes to test exported symbols flushed out the fact
 that we were unconditionally linking against symbols that were
 only conditionally compiled under HAVE_AVAHI.

 * src/Makefile.am (libvirt_net_rpc_server_la_SOURCES): Compile
 virnetservermdns unconditionally.
 * configure.ac (HAVE_AVAHI): Drop unused automake conditional.
 * src/rpc/virnetservermdns.c: Add fallbacks when Avahi is not
 present.

 ---

 Definitely more involved than splitting out a separate .syms file, so
 I'm not sure whether this approach is better than the v1 approach.
 But I did promise to propose this alternative, so here it is.  I tested
 both with and without avahi development libraries present.

  configure.ac   |  1 -
  src/Makefile.am|  8 +---
  src/rpc/virnetservermdns.c | 98 
 ++
  3 files changed, 91 insertions(+), 16 deletions(-)
 
 Hmm, there should be a change to src/rpc/virnetserver.c to
 remove the avahi conditionals there I think.

I will have to do that as a followup patch; this patch made creation of
a new object always fail, but the virnetserver code assumes that if the
object creation call exists, then it is usable.  So it is not just a
trivial removal of #ifdef HAVE_AVAHI, but some actual changes to the
fallback code to be a useful no-op.

  If everything
 still operates when avahi is disabled, then I think I prefer
 this patch, even though it is more complex, because it means
 the HAVE_AVAHI conditionals don't spread across the source
 tree to every user of this API.
 
 ACK

I've gone ahead and pushed this, for build reasons, while working on the
followup.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2][TCK 1/2] Extend image and memory size for installing guest

2012-08-02 Thread Eric Blake
On 08/02/2012 05:04 AM, Guannan Ren wrote:
 On 08/01/2012 06:01 PM, Kyla Zhang wrote:
 In fedora 17 with less than 512M memory will cause installation hang,
 also the previous image size is too small, so improve them.
 ---

 
Install in a VM with 512MB RAM freezes forever at Trying to
 unpack rootfs image as initramfs
We encounter this problem on fedora17.
The same problem happened before:
https://bugzilla.redhat.com/show_bug.cgi?id=707481
Most of testing machine should have more than 1 GB memory, so
 change the code.
Kyla, you'd better give more infomation in git commite log next
 time, describe your problem and
why we need to change it.
 
ACK.

I've updated the commit message, and pushed.
-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2 1/3] Add per-guest S3/S4 state configuration

2012-08-02 Thread Eric Blake
On 08/02/2012 06:05 AM, Martin Kletzander wrote:
 There is a new pm/ element implemented that can control what ACPI
 sleeping states will be advertised by BIOS and allowed to be switched
 to by libvirt. The default keeps defaults on hypervisor, otherwise
 forces chosen setting.

You are proposing /domain/pm; but we also have /domain/os/bios, would
this be better as a subelement /domain/os/bios/pm, since it is related
to bios options?

 ---
  docs/schemas/domaincommon.rng |   33 ++
  src/conf/domain_conf.c|   44 
 +
  src/conf/domain_conf.h|   14 +
  src/libvirt_private.syms  |2 +
  4 files changed, 93 insertions(+), 0 deletions(-)
 

 @@ -2192,6 +2195,36 @@
  /choice
/define
!--
 +  Control ACPI sleep states (dis)allowed for the domain
 +  For each of the states the following rules apply:
 +  on: the state will be forcefully enabled
 +  off: the state will be forcefully disabled
 +  not specified: hypervisor will be left to decide its defaults
 +  --
 +  define name=pm
 +element name=pm
 +  interleave
 +optional
 +  attribute name=s3

Is the name 's3' too x86-centric?  Remember, for
virNodeSuspendForDuration, we went with the names 'mem' (s3) and 'disk'
(s4) to give a more descriptive naming for where we were suspending.  So
controlling whether s3 is advertised is really controlling whether
'suspend-to-memory' is advertised.

 +++ b/src/conf/domain_conf.h
 @@ -1372,6 +1372,14 @@ enum virDomainLifecycleCrashAction {
  VIR_DOMAIN_LIFECYCLE_CRASH_LAST
  };
 
 +enum virDomainPMState {
 +VIR_DOMAIN_PM_STATE_DEFAULT = 0,
 +VIR_DOMAIN_PM_STATE_ON,
 +VIR_DOMAIN_PM_STATE_OFF,
 +
 +VIR_DOMAIN_PM_STATE_LAST,
 +};
 +
  enum virDomainBIOSUseserial {
  VIR_DOMAIN_BIOS_USESERIAL_DEFAULT = 0,
  VIR_DOMAIN_BIOS_USESERIAL_YES,
 @@ -1618,6 +1626,11 @@ struct _virDomainDef {
  int onPoweroff;
  int onCrash;
 
 +struct {
 +int s3;
 +int s4;

Add a comment that these values are type enum virDomainPMState.

The code itself looks decent (and thanks for the test cases), but I'd
like a second opinion on whether the choice of XML naming is the best;
if we choose a different naming scheme, I think you should be able to
adapt the rest of the patch pretty easily.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2] Update xml schemas according to libvirt source

2012-08-02 Thread Eric Blake
On 08/02/2012 05:23 AM, Ján Tomko wrote:
 capability.rng: Guest features can be in any order.
 nodedev.rng: Added driver element, capability phys_function and
 virt_functions for PCI devices.
 storagepool.rng: Owner or group ID can be -1.
 
 schema tests: New capabilities and nodedev files; changed owner and
 group to -1 in pool-dir.xml.
 storage_conf: Print uid_t and gid_t as signed to storage pool XML.
 ---
 v2: New tests and signed uid_t and gid_t printing. This feels slightly
 less wrong than testing for 4294967295.

Thanks; this looks better.

ACK and pushed.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2 2/3] qemu: Add support for S3/S4 state configuration

2012-08-02 Thread Eric Blake
On 08/02/2012 06:05 AM, Martin Kletzander wrote:
 This patch adds support for running qemu guests with the required
 parameters to forcefully enable or disable BIOS advertising of S3 and
 S4 states.  The support for this is added to capabilities and there is
 also a qemu command parameter parsing implemented.
 ---
  src/qemu/qemu_capabilities.c |7 +++
  src/qemu/qemu_capabilities.h |2 +
  src/qemu/qemu_command.c  |  103 
 ++
  src/qemu/qemu_driver.c   |   17 +++
  4 files changed, 129 insertions(+), 0 deletions(-)
 
 diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
 index 85c49a2..b4a662f 100644
 --- a/src/qemu/qemu_capabilities.c
 +++ b/src/qemu/qemu_capabilities.c
 @@ -169,6 +169,8 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
virtio-s390,
balloon-event,
 
 +  disable-s3, /* 100 */
 +  disable-s4,

Do we need two capability bits here, or are we guaranteed that both
command line options are always present or absent together and one bit
sufficient?  If we use just one bit, maybe naming it 'disable-pm' would
be reasonable.  Then again, the qemu folks might say that it really
should be two independent bits, such as if it is easier to backport just
one of the two controls to an older qemu.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v5 6/6] block: Enable qemu_open/close to work with fd sets

2012-08-02 Thread Corey Bryant



On 07/23/2012 09:14 AM, Corey Bryant wrote:



On 07/23/2012 09:08 AM, Corey Bryant wrote:

When qemu_open is passed a filename of the /dev/fdset/nnn
format (where nnn is the fdset ID), an fd with matching access
mode flags will be searched for within the specified monitor
fd set.  If the fd is found, a dup of the fd will be returned
from qemu_open.

Each fd set has a reference count.  The purpose of the reference
count is to determine if an fd set contains file descriptors that
have open dup() references that have not yet been closed.  It is
incremented on qemu_open and decremented on qemu_close.  It is
not until the refcount is zero that file desriptors in an fd set
can be closed.  If an fd set has dup() references open, then we
must keep the other fds in the fd set open in case a reopen
of the file occurs that requires an fd with a different access
mode.

Signed-off-by: Corey Bryant cor...@linux.vnet.ibm.com

v2:
  -Get rid of file_open and move dup code to qemu_open
   (kw...@redhat.com)
  -Use strtol wrapper instead of atoi (kw...@redhat.com)

v3:
  -Add note about fd leakage (ebl...@redhat.com)

v4
  -Moved patch to be later in series (lcapitul...@redhat.com)
  -Update qemu_open to check access mode flags and set flags that
   can be set (ebl...@redhat.com, kw...@redhat.com)

v5:
  -This patch was overhauled quite a bit in this version, with
   the addition of fd set and refcount support.
  -Use qemu_set_cloexec() on dup'd fd (ebl...@redhat.com)
  -Modify flags set by fcntl on dup'd fd (ebl...@redhat.com)
  -Reduce syscalls when setting flags for dup'd fd (ebl...@redhat.com)
  -Fix O_RDWR, O_RDONLY, O_WRONLY checks (ebl...@redhat.com)
---
  block/raw-posix.c |   24 +-
  block/raw-win32.c |2 +-
  block/vmdk.c  |4 +-
  block/vpc.c   |2 +-
  block/vvfat.c |   12 ++---
  cutils.c  |5 ++
  monitor.c |   85 +
  monitor.h |4 ++
  osdep.c   |  138
-
  qemu-common.h |3 +-
  qemu-tool.c   |   12 +
  11 files changed, 267 insertions(+), 24 deletions(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index a172de3..5d0a801 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -271,7 +271,7 @@ static int raw_open_common(BlockDriverState *bs,
const char *filename,
  out_free_buf:
  qemu_vfree(s-aligned_buf);
  out_close:
-qemu_close(fd);
+qemu_close(fd, filename);
  return -errno;
  }

@@ -376,7 +376,7 @@ static void raw_close(BlockDriverState *bs)
  {
  BDRVRawState *s = bs-opaque;
  if (s-fd = 0) {
-qemu_close(s-fd);
+qemu_close(s-fd, bs-filename);
  s-fd = -1;
  if (s-aligned_buf != NULL)
  qemu_vfree(s-aligned_buf);
@@ -580,7 +580,7 @@ static int raw_create(const char *filename,
QEMUOptionParameter *options)
  if (ftruncate(fd, total_size * BDRV_SECTOR_SIZE) != 0) {
  result = -errno;
  }
-if (qemu_close(fd) != 0) {
+if (qemu_close(fd, filename) != 0) {
  result = -errno;
  }
  }
@@ -850,7 +850,7 @@ static int hdev_open(BlockDriverState *bs, const
char *filename, int flags)
  if (fd  0) {
  bsdPath[strlen(bsdPath)-1] = '1';
  } else {
-qemu_close(fd);
+qemu_close(fd, bsdPath);
  }
  filename = bsdPath;
  }
@@ -889,7 +889,7 @@ static int fd_open(BlockDriverState *bs)
  last_media_present = (s-fd = 0);
  if (s-fd = 0 
  (get_clock() - s-fd_open_time) = FD_OPEN_TIMEOUT) {
-qemu_close(s-fd);
+qemu_close(s-fd, bs-filename);
  s-fd = -1;
  #ifdef DEBUG_FLOPPY
  printf(Floppy closed\n);
@@ -988,7 +988,7 @@ static int hdev_create(const char *filename,
QEMUOptionParameter *options)
  else if (lseek(fd, 0, SEEK_END)  total_size * BDRV_SECTOR_SIZE)
  ret = -ENOSPC;

-qemu_close(fd);
+qemu_close(fd, filename);
  return ret;
  }

@@ -1038,7 +1038,7 @@ static int floppy_open(BlockDriverState *bs,
const char *filename, int flags)
  return ret;

  /* close fd so that we can reopen it as needed */
-qemu_close(s-fd);
+qemu_close(s-fd, filename);
  s-fd = -1;
  s-fd_media_changed = 1;

@@ -1070,7 +1070,7 @@ static int floppy_probe_device(const char
*filename)
  prio = 100;

  outc:
-qemu_close(fd);
+qemu_close(fd, filename);
  out:
  return prio;
  }
@@ -1105,14 +1105,14 @@ static void floppy_eject(BlockDriverState *bs,
bool eject_flag)
  int fd;

  if (s-fd = 0) {
-qemu_close(s-fd);
+qemu_close(s-fd, bs-filename);
  s-fd = -1;
  }
  fd = qemu_open(bs-filename, s-open_flags | O_NONBLOCK);
  if (fd = 0) {
  if (ioctl(fd, FDEJECT, 0)  0)
  perror(FDEJECT);
-qemu_close(fd);
+qemu_close(fd, bs-filename);
  }
  }

@@ 

Re: [libvirt] [PATCH v2] qemu: Allow to attach/detach controller device persistently

2012-08-02 Thread Eric Blake
On 07/23/2012 02:18 AM, Osier Yang wrote:
 * src/conf/domain_conf.c:
   - Add virDomainControllerFind to find controller device by type
 and index.
   - Add virDomainControllerRemove to remove the controller device
 from maintained controler list.

s/controler/controller/

 
 * src/conf/domain_conf.h:
   - Declare the two new helpers.
 
 * src/libvirt_private.syms:
   - Expose private symbols for the two new helpers.
 
 * src/qemu/qemu_driver.c:
   - Support attach/detach controller device persistently
 
 * src/qemu/qemu_hotplug.c:
   - Use the two helpers to simplify the codes.
 
 v1 - v2:
   - Allow to detach the controller too.
 +virDomainControllerDefPtr
 +virDomainControllerRemove(virDomainDefPtr def, size_t i)
 +{
 +virDomainControllerDefPtr controller = def-controllers[i];
 +
 +if (def-ncontrollers  1) {
 +memmove(def-controllers + i,
 +def-controllers + i + 1,
 +sizeof(*def-controllers) *
 +(def-ncontrollers - (i + 1)));
 +def-ncontrollers--;
 +if (VIR_REALLOC_N(def-controllers, def-ncontrollers)  0) {
 +/* ignore, harmless */

VIR_SHRINK_N is nicer, it lets you omit the lame comment.

ACK.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] Added timestamps to storage volumes

2012-08-02 Thread Eric Blake
On 07/25/2012 01:43 AM, Hendrik Schwartke wrote:
 The access, birth, modification and change times are added to
 storage volumes and corresponding xml representations.

Listing the actual output XML in the commit message will help future
readers.

 ---
  bootstrap.conf|1 +
  docs/formatstorage.html.in|   16 
  docs/schemas/storagevol.rng   |   34 ++
  src/conf/storage_conf.c   |   20 
  src/conf/storage_conf.h   |   13 +
  src/storage/storage_backend.c |6 ++
  6 files changed, 90 insertions(+)

We should really update at least one test to validate our rng changes.
For that matter, 'make check' fails without at least some updates,
because your code blindly outputs timestamps with contents of 0 for a
default-initialized struct, and with no way to parse input, the xml2xml
round-trip test can't validate our output code.

 +++ b/docs/formatstorage.html.in
 @@ -141,6 +141,11 @@
  lt;modegt;0744lt;/modegt;
  lt;labelgt;virt_image_tlt;/labelgt;
lt;/permissionsgt;
 +  lt;timestampsgt;
 +lt;atimegt;1341933637.27319099lt;/atimegt;

That's only 8 digits for subsecond resolution.  Are you truncating a
trailing 0, or are you missing a leading 0?  Thinking about it more,
it's easier for end users to parse a fixed-length 9-digit number with
trailing zeros and always have it be scaled correctly than it is to make
them parse an arbitrary length number and then scale it to 9 digits, so
I'd prefer leaving trailing zeros intact and only omit the subsecond
resolution when it is exactly 0, at least on output.

 @@ -172,6 +177,17 @@
  contains the MAC (eg SELinux) label string.
  span class=sinceSince 0.4.1/span
/dd
 +  dtcodetimestamps/code/dt
 +  ddProvides timing information about the volume. Up to four 
 sub-elements are
 +present, where codeatime/code, codebtime/code, 
 codectime/code
 +and codemtime/code hold the access, birth, change and 
 modification time
 +of the volume, where known. The used time format is
 +lt;secondsgt;.lt;nanosecondsgt; since the beginning of the 
 epoch. If
 +nanosecond resolution isn't supported by the host OS or filesystem 
 then the
 +nanoseconds part is omitted. It is also omitted when zero. This is a
 +readonly attribute and is ignored when creating a volume.
 +span class=sinceSince 0.10.0/span

Long lines; I reformatted to fit in 80 columns.

Technically, while btime and ctime must be ignored (as we can't
really fake them), we could use futimens during creation to honor
atime and mtime as a future extension, if we thought it was worth
the ability to let people create volumes with hand-controlled
timestamps.  Doesn't affect this patch, though.

 +++ b/docs/schemas/storagevol.rng
 @@ -63,6 +63,39 @@
  /optional
/define
  
 +  define name='timestamps'
 +optional
 +  element name='timestamps'
 +optional
 +  element name='atime'
 +ref name='timestamp'/
 +  /element
 +/optional

If we want to allow creation to specify timestamps, then we should allow
interleave of these subelements.  In fact, I see no harm in allowing
that now.

 +
 +  define name='timestamp'
 +data type='string'
 +  param name=pattern[0-9]+(\.[0-9]+)?/param

On output, we could enforce {9} instead of + in this regex.  But if we
ever allow input, then this is too strict (we want {0,9} to allow the
user to give a shortened form, and deal with scaling the value
appropriately on our input parse).

 @@ -1277,6 +1290,13 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr 
 options,
  
  virBufferAddLit(buf,/permissions\n);
  
 +virBufferAddLit(buf, timestamps\n);
 +virStorageVolTimestampFormat(buf, atime, def-timestamps.atime);
 +virStorageVolTimestampFormat(buf, btime, def-timestamps.btime);
 +virStorageVolTimestampFormat(buf, ctime, def-timestamps.ctime);
 +virStorageVolTimestampFormat(buf, mtime, def-timestamps.mtime);

I really do think laying this out in 'struct stat' order makes more
sense; atim, mtim, ctim, then btim.  XPath notation will be able to find
it regardless of our ordering.

I don't know why we use -Waggregate-return; gcc doesn't like stat-time.h
as a result; so I had to disable it for now; maybe upstream gnulib will
let us change the signature to something that modifies a pointer
argument instead of returning an aggregate, but that's a change for down
the road.

Another nice followup patch would be adding timestamps to directory
storagepool output XML.

Everything else looked good.  Thanks again for your patience.  Here's
what I squashed in, before pushing:

diff --git i/docs/formatstorage.html.in w/docs/formatstorage.html.in
index 2a578e9..9f93db8 100644
--- i/docs/formatstorage.html.in
+++ w/docs/formatstorage.html.in
@@ -142,9 +142,9 @@
 

Re: [libvirt] [PATCH v2][TCK 2/2] Add test for memory set and get

2012-08-02 Thread Wei Zhang
Thanks for detailed modification. I will repatch after testing on xen.

- Original Message -
 On 08/01/2012 06:01 PM, Kyla Zhang wrote:
  Add test for memory/maxmem set and get on domain running/shutdown
  ---
scripts/domain/310-memory-set-get.t |   98
+++
1 files changed, 98 insertions(+), 0 deletions(-)
create mode 100644 scripts/domain/310-memory-set-get.t
 
  diff --git a/scripts/domain/310-memory-set-get.t
  b/scripts/domain/310-memory-set-get.t
  new file mode 100644
  index 000..71886a6
  --- /dev/null
  +++ b/scripts/domain/310-memory-set-get.t
  @@ -0,0 +1,98 @@
  +# -*- perl -*-
  +#
  +# Copyright (C) 2012-2013 Red Hat, Inc.
  +# Copyright (C) 2012-2013 Kyla Zhang weiz...@redhat.com
  +#
  +# This program is free software; You can redistribute it and/or
  modify
  +# it under the GNU General Public License as published by the Free
  +# Software Foundation; either version 2, or (at your option) any
  +# later version
  +#
  +# The file LICENSE distributed along with this file provides
  full
  +# details of the terms and conditions
  +#
  +
  +=pod
  +
  +=head1 NAME
  +
  +domain/310-memory-set-get.t: test set and get memory/max memory
 
   Could we use small number rather than 310.
 
  +
  +=head1 DESCRIPTION
  +
  +The test case validates that the set memory, set max memory and
  get
  +max memory works well for domain.
 
The testcase validates the basic function of domain memory
 balloon via
setting its value of current memory, max memory.
 
  +
  +=cut
  +
  +use strict;
  +use warnings;
  +
  +use Test::More tests = 15;
  +
  +use Sys::Virt::TCK;
  +use Sys::Virt::TCK::NetworkHelpers;
  +use Test::Exception;
  +use File::Spec::Functions qw(catfile catdir rootdir);
  +
  +my $tck = Sys::Virt::TCK-new();
  +my $conn = eval { $tck-setup(); };
  +BAIL_OUT failed to setup test harness: $@ if $@;
  +END { $tck-cleanup if $tck; }
  +
  +diag Define a new real domain, default memory is 1048576;
 
  my $current_mem = 1048576;
  my $max_mem = 1572864;
  my $config_mem = 924288;
  diag Defing a guest with memory size $current_mem KiB;
 
 
  +my $dom_name =tck310memtest;
 
 $dom_name = tckmemballoon
 
 
  +
  +my $dom = prepare_test_disk_and_vm($tck, $conn, $dom_name);
  +
  +diag Set max memory for domain;
 
  diag Setting maximum memory for inactive domain
 
 
  +lives_ok(sub { $dom-set_max_memory(1572864) }, Set max memory
  succeed);
 
 
   lives_ok(sub { $dom-set_max_memory($max_mem) }, Set max
 memory $max_mem);
 
 
  +
  +diag Get max memory for domain when domain is inactive;
 
   diag Get maximum memory from the inactive domain;
 
 
  +is($dom-get_max_memory(), 1572864, Get max memory is same as set
  value 1572864);
 
is($dom-get_max_memory(),  $max_mem, Got max memory
 $max_mem);
 
 
  +
  +diag Start inactive domain;
 
  diag Starting domain;
 
 
  +$dom-create;
  +ok($dom-get_id()  0, running domain has an ID  0);
  +sleep(30);
  +
  +diag Set memory for current state;
 
 diag Setting  memory with flag MEM_CONFIG;
 
 
  +lives_ok(sub { $dom-set_memory(924288,
  Sys::Virt::Domain::MEM_CONFIG) }, Set memory succeed in
  persistent config);
 
   lives_ok(sub { $dom-set_memory($config_mem,
 Sys::Virt::Domain::MEM_CONFIG) }, Set persistent memory value
 $config_mem);
 
 
  +
  +diag get memory of running domain;
 
  diag Get current memory;
 
  +is($dom-get_info()-{memory}, 1048576, Get current memory is
  1048576);
  +
  +diag Get max memory for domain when domain is active;
  +is($dom-get_max_memory(), 1572864, Get max memory is same as set
  value 1572864);
  +
  +diag Set memory for current state;
  +lives_ok(sub { $dom-set_memory(724288,
  Sys::Virt::Domain::MEM_CURRENT) }, Set memory succeed in current
  state);
  +sleep(3);
  +
  +diag Check memory of running domain;
  +is($dom-get_info()-{memory}, 724288, Get current memory is same
  as set value 724288);
  +
  +diag Set memory for live state;
  +lives_ok(sub { $dom-set_memory(824288,
  Sys::Virt::Domain::MEM_LIVE) }, Set memory succeed in live
  state);
  +sleep(3);
  +
  +diag Check memory of running domain;
  +is($dom-get_info()-{memory}, 824288, Get current memory is same
  as set value 824288);
  +
  +diag Try setting max memory when domain is running;
  +ok_error(sub { $dom-set_max_memory(1048576) }, not allowed to
  set max memory when domain is running);
  +
  +diag Destroying the transient domain;
  +$dom-destroy;
  +
  +diag Check memory of shutdown domain;
  +is($dom-get_info()-{memory}, 924288, Get memory is 624288 when
  domain is shutdown);
  +
  +diag Set max memory with set_memory;
  +lives_ok(sub { $dom-set_memory(1148576,
  Sys::Virt::Domain::MEM_MAXIMUM) }, Set max memory succeed with
  set_memory);
  +
  +diag Get max memory for domain;
  +is($dom-get_info()-{maxMem}, 1148576, Get max memory is same as
  set value 1148576);

Re: [libvirt] [PATCH v2] qemu: Allow to attach/detach controller device persistently

2012-08-02 Thread Osier Yang

On 2012年08月03日 06:29, Eric Blake wrote:

On 07/23/2012 02:18 AM, Osier Yang wrote:

* src/conf/domain_conf.c:
   - Add virDomainControllerFind to find controller device by type
 and index.
   - Add virDomainControllerRemove to remove the controller device
 from maintained controler list.


s/controler/controller/



* src/conf/domain_conf.h:
   - Declare the two new helpers.

* src/libvirt_private.syms:
   - Expose private symbols for the two new helpers.

* src/qemu/qemu_driver.c:
   - Support attach/detach controller device persistently

* src/qemu/qemu_hotplug.c:
   - Use the two helpers to simplify the codes.

v1 - v2:
   - Allow to detach the controller too.
+virDomainControllerDefPtr
+virDomainControllerRemove(virDomainDefPtr def, size_t i)
+{
+virDomainControllerDefPtr controller = def-controllers[i];
+
+if (def-ncontrollers  1) {
+memmove(def-controllers + i,
+def-controllers + i + 1,
+sizeof(*def-controllers) *
+(def-ncontrollers - (i + 1)));
+def-ncontrollers--;
+if (VIR_REALLOC_N(def-controllers, def-ncontrollers)  0) {
+/* ignore, harmless */


VIR_SHRINK_N is nicer, it lets you omit the lame comment.

ACK.



Thanks, I pushed it as-is, and will clean up the similar
VIR_REALLOC_N use together as a separate patch (Most of the
*$DeviceRemove funcs use it).

Regards,
Osier

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] Add APIs for obtaining the unique ID of LVM SCSI volumes

2012-08-02 Thread Doug Goldstein
On Thu, Aug 2, 2012 at 8:09 AM, Daniel P. Berrange berra...@redhat.com wrote:
 From: Daniel P. Berrange berra...@redhat.com

 Both LVM volumes and SCSI LUNs have a globally unique
 identifier associated with them. It is useful to be able
 to query this identifier to then perform disk locking,
 rather than try to figure out a stable pathname.
 --

Would it not be better to call methods from within libdevmapper and
libblkid than relying on a callout? Its also worth noting that iSCSI
provides a GUID for the volume as well.

-- 
Doug Goldstein

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v2 1/3] Add per-guest S3/S4 state configuration

2012-08-02 Thread Doug Goldstein
On Thu, Aug 2, 2012 at 3:36 PM, Eric Blake ebl...@redhat.com wrote:
 On 08/02/2012 06:05 AM, Martin Kletzander wrote:
 There is a new pm/ element implemented that can control what ACPI
 sleeping states will be advertised by BIOS and allowed to be switched
 to by libvirt. The default keeps defaults on hypervisor, otherwise
 forces chosen setting.

 You are proposing /domain/pm; but we also have /domain/os/bios, would
 this be better as a subelement /domain/os/bios/pm, since it is related
 to bios options?

I would say that /domain/os/bios/pm isn't the correct place because
/domain/os relates only to OS booting while Power Management is
outside of the scope of booting. In fact /domain/os/bios simply
controls whether the BIOS output will be over VGA or over serial.
Features specific to the system are typically kept as top level items,
which matches /domain/pm. I would however say that using the terms
ACPI, s3 and s4 isn't good design for the XML. You can leave that to
documentation but /domain/pm/suspend-to-mem and
/domain/pm/suspend-to-disk are better so that the same XML structure
can be used for PPC. They have concepts similar to s3 and s4 (I only
briefly Googled this) but they're named completely differently. The
only under place I could see this would be /domain/features/acpi. If
its there then s3 and s4 potentially make sense, but then we're left
without a place for PPC to tie in.

-- 
Doug Goldstein

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] build: fix make rpm

2012-08-02 Thread Laine Stump
make rpm was failing with the following error:

Entering directory `/home/laine/devel/libvirt/tests'
make[2]: *** No rule to make target `viratomicdata.h',
 needed by `distdir'.  Stop.

viratomicdata.h is listed in tests/Makefile.am as a dependency of
viratomictest, but doesn't exist, is never referenced, and removing
that dependency permits make rpm to complete successfully.

I'm assuming this was a cut-paste error, or a half-finished idea, but
since I didn't know for sure, I didn't push this patch, even though it
fixes a broken build.
---
 tests/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index ac26bc5..2fdaace 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -531,7 +531,7 @@ virhashtest_SOURCES = \
 virhashtest_LDADD = $(LDADDS)
 
 viratomictest_SOURCES = \
-   viratomictest.c viratomicdata.h testutils.h testutils.c
+   viratomictest.c testutils.h testutils.c
 viratomictest_LDADD = $(LDADDS)
 
 jsontest_SOURCES = \
-- 
1.7.11.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list