Re: [libvirt] [PATCH] qemu: Fix startupPolicy for snapshot-revert

2012-03-08 Thread Michal Privoznik
On 07.03.2012 19:36, Eric Blake wrote:
 On 03/07/2012 11:19 AM, Michal Privoznik wrote:
 Currently, startupPolicy='requisite' was determining cold boot
 by migrateForm != NULL. That means, if domain was started up
 with migrateForm set we didn't require disk source path and allowed
 
 s/migrateForm/migrateFrom/ (twice)
 
 it to be dropped. However, on snapshot-revert domain wasn't migrated
 but according to documentation, requisite should drop disk source
 as well.
 ---

 Related BZ: https://bugzilla.redhat.com/show_bug.cgi?id=798938

  src/qemu/qemu_driver.c|   16 +---
  src/qemu/qemu_migration.c |2 +-
  src/qemu/qemu_process.c   |3 ++-
  src/qemu/qemu_process.h   |1 +
  4 files changed, 13 insertions(+), 9 deletions(-)

 
 @@ -4107,8 +4107,9 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
  }
  
  /* Set the migration source and start it up. */
 -ret = qemuProcessStart(conn, driver, vm, stdio, true,
 -   false, *fd, path, NULL, 
 VIR_NETDEV_VPORT_PROFILE_OP_RESTORE);
 +ret = qemuProcessStart(conn, driver, vm, stdio, false, true,
 +   false, *fd, path, NULL,
 
 Yuck - we're starting to rack up so many bools that it's hard to tell
 which one is which.  This patch can go in as-is, but I'd also like to
 see a followup patch that refactors things into using an 'unsigned int
 flags' with an internal enum for bit values (QEMU_START_COLD,
 QEMU_START_PAUSED, QEMU_START_AUTODESTROY, ...).
 
 ACK.
 

Thanks pushed. And I'll send patch for what you've described.

Michal

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


[libvirt] [PATCH 0/7] Various bugfixes related to device management

2012-03-08 Thread Laine Stump
This series contains 7 patches that are mostly related by the face
that I noticed the problems they're solving while writing the
interface type='hostdev' code during the past couple weeks. After
that series was pushed, I sat down to fix everything I'd noticed
before I forgot about it. I'm sending it as a single series rather
than individual patches just to that they're easier to keep track of.

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


[libvirt] [PATCH 1/7] util: consolidate duplicated error messages in virnetlink.c

2012-03-08 Thread Laine Stump
There are special stub versions of all public functions in this file
that are compiled when either libnl isn't available or the platform
isn't linux. Each of these functions had two almost identical message,
differing only in the function name included in the message. Since log
messages already contain the function name, we can just define a const
char* with the common part of the string, and use that same string for
all the log messages.

Also, rather than doing #if defined ... #else ... #endif *inside the
error log macro invocation*, this patch does #if defined ... just
once, using it to decide which single string to define. This turns the
error log in each function from 6 lines, to 1 line.
---
 src/util/virnetlink.c |   47 ---
 1 files changed, 12 insertions(+), 35 deletions(-)

diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index 59f3e39..77dde9f 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -525,17 +525,18 @@ cleanup:
 
 #else
 
+# if defined(__linux)  !defined(HAVE_LIBNL)
+static const char *unsupported = _(libnl was not available at build time);
+# else
+static const char *unsupported = _(not supported on non-linux platforms);
+# endif
+
 int virNetlinkCommand(struct nl_msg *nl_msg ATTRIBUTE_UNUSED,
unsigned char **respbuf ATTRIBUTE_UNUSED,
unsigned int *respbuflen ATTRIBUTE_UNUSED,
int nl_pid ATTRIBUTE_UNUSED)
 {
-netlinkError(VIR_ERR_INTERNAL_ERROR, %s,
-# if defined(__linux__)  !defined(HAVE_LIBNL)
- _(virNetlinkCommand is not supported since libnl was not 
available));
-# else
- _(virNetlinkCommand is not supported on non-linux 
platforms));
-# endif
+netlinkError(VIR_ERR_INTERNAL_ERROR, %s, unsupported);
 return -1;
 }
 
@@ -545,11 +546,7 @@ int virNetlinkCommand(struct nl_msg *nl_msg 
ATTRIBUTE_UNUSED,
  */
 int virNetlinkEventServiceStop(void)
 {
-# if defined(__linux__)  !defined(HAVE_LIBNL)
-netlinkError(VIR_ERR_INTERNAL_ERROR,
-%s,
-_(virNetlinkEventServiceStop is not supported since libnl was 
not available));
-# endif
+netlinkError(VIR_ERR_INTERNAL_ERROR, %s, unsupported);
 return 0;
 }
 
@@ -559,11 +556,7 @@ int virNetlinkEventServiceStop(void)
  */
 int virNetlinkEventServiceStart(void)
 {
-# if defined(__linux__)  !defined(HAVE_LIBNL)
-netlinkError(VIR_ERR_INTERNAL_ERROR,
-%s,
-_(virNetlinkEventServiceStart is not supported since libnl 
was not available));
-# endif
+netlinkError(VIR_ERR_INTERNAL_ERROR, %s, unsupported);
 return 0;
 }
 
@@ -573,11 +566,7 @@ int virNetlinkEventServiceStart(void)
  */
 bool virNetlinkEventServiceIsRunning(void)
 {
-# if defined(__linux__)  !defined(HAVE_LIBNL)
-netlinkError(VIR_ERR_INTERNAL_ERROR,
-%s,
-_(virNetlinkEventServiceIsRunning is not supported since 
libnl was not available));
-# endif
+netlinkError(VIR_ERR_INTERNAL_ERROR, %s, unsupported);
 return 0;
 }
 
@@ -590,13 +579,7 @@ int virNetlinkEventAddClient(virNetlinkEventHandleCallback 
handleCB ATTRIBUTE_UN
  void *opaque ATTRIBUTE_UNUSED,
  const unsigned char *macaddr ATTRIBUTE_UNUSED)
 {
-netlinkError(VIR_ERR_INTERNAL_ERROR,
-%s,
-# if defined(__linux__)  !defined(HAVE_LIBNL)
-_(virNetlinkEventServiceAddClient is not supported since 
libnl was not available));
-# else
-_(virNetlinkEventServiceAddClient is not supported on 
non-linux platforms));
-# endif
+netlinkError(VIR_ERR_INTERNAL_ERROR, %s, unsupported);
 return -1;
 }
 
@@ -606,13 +589,7 @@ int virNetlinkEventAddClient(virNetlinkEventHandleCallback 
handleCB ATTRIBUTE_UN
 int virNetlinkEventRemoveClient(int watch ATTRIBUTE_UNUSED,
 const unsigned char *macaddr ATTRIBUTE_UNUSED)
 {
-netlinkError(VIR_ERR_INTERNAL_ERROR,
-%s,
-# if defined(__linux__)  !defined(HAVE_LIBNL)
-_(virNetlinkEventRemoveClient is not supported since libnl 
was not available));
-# else
-_(virNetlinkEventRemoveClient is not supported on non-linux 
platforms));
-# endif
+netlinkError(VIR_ERR_INTERNAL_ERROR, %s, unsupported);
 return -1;
 }
 
-- 
1.7.7.6

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


[libvirt] [PATCH 3/7] qemu: don't 'remove' hostdev objects from domain if operation fails

2012-03-08 Thread Laine Stump
There were certain paths through the hostdev detach code that could
lead to the lower level function failing (and not removing the object
from the domain's hostdevs list), but the higher level function
free'ing the hostdev object anyway. This would leave a stale
hostdevdef pointer in the list, which would surely cause a problem
eventually.

This patch relocates virDomainHostdevRemove from the lower level
functions qemuDomainDetachThisHostDevice and
qemuDomainDetachHostPciDevice, to their caller
qemuDomainDetachThisHostDevice, placing it just before the call to
virDomainHostdevDefFree. This makes it easy to verify that either both
operations are done, or neither.

NB: The dangling pointer part of this problem was introduced in
commit 13d5a6, so it is not present in libvirt versions prior to
0.9.9. Earlier versions would return failure in certain cases even
though the the device object was removed/deleted, but the removal and
deletion operations would always both happen or neither.
---
 src/qemu/qemu_hotplug.c |   28 
 1 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index c5ed9f7..22d0231 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1852,8 +1852,7 @@ cleanup:
 static int
 qemuDomainDetachHostPciDevice(struct qemud_driver *driver,
   virDomainObjPtr vm,
-  virDomainHostdevDefPtr detach,
-  int idx)
+  virDomainHostdevDefPtr detach)
 {
 qemuDomainObjPrivatePtr priv = vm-privateData;
 virDomainHostdevSubsysPtr subsys = detach-source.subsys;
@@ -1914,15 +1913,13 @@ qemuDomainDetachHostPciDevice(struct qemud_driver 
*driver,
 detach-info-addr.pci.slot)  0)
 VIR_WARN(Unable to release PCI address on host device);
 
-virDomainHostdevRemove(vm-def, idx);
 return ret;
 }
 
 static int
 qemuDomainDetachHostUsbDevice(struct qemud_driver *driver,
   virDomainObjPtr vm,
-  virDomainHostdevDefPtr detach,
-  int idx)
+  virDomainHostdevDefPtr detach)
 {
 qemuDomainObjPrivatePtr priv = vm-privateData;
 virDomainHostdevSubsysPtr subsys = detach-source.subsys;
@@ -1956,8 +1953,6 @@ qemuDomainDetachHostUsbDevice(struct qemud_driver *driver,
 VIR_WARN(Unable to find device %03d.%03d in list of used USB devices,
  subsys-u.usb.bus, subsys-u.usb.device);
 }
-
-virDomainHostdevRemove(vm-def, idx);
 return ret;
 }
 
@@ -1987,10 +1982,10 @@ int qemuDomainDetachThisHostDevice(struct qemud_driver 
*driver,
 
 switch (detach-source.subsys.type) {
 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
-ret = qemuDomainDetachHostPciDevice(driver, vm, detach, idx);
-   break;
+ret = qemuDomainDetachHostPciDevice(driver, vm, detach);
+break;
 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
-ret = qemuDomainDetachHostUsbDevice(driver, vm, detach, idx);
+ret = qemuDomainDetachHostUsbDevice(driver, vm, detach);
 break;
 default:
 qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -1999,13 +1994,14 @@ int qemuDomainDetachThisHostDevice(struct qemud_driver 
*driver,
 return -1;
 }
 
-if (ret == 0 
-virSecurityManagerRestoreHostdevLabel(driver-securityManager,
-  vm-def, detach)  0) {
-VIR_WARN(Failed to restore host device labelling);
+if (!ret) {
+if (virSecurityManagerRestoreHostdevLabel(driver-securityManager,
+  vm-def, detach)  0) {
+VIR_WARN(Failed to restore host device labelling);
+}
+virDomainHostdevRemove(vm-def, idx);
+virDomainHostdevDefFree(detach);
 }
-
-virDomainHostdevDefFree(detach);
 return ret;
 }
 
-- 
1.7.7.6

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


[libvirt] [PATCH 2/7] util: make virDomainLeaseDefFree global

2012-03-08 Thread Laine Stump
It will be used in a different file in an upcoming patch.
---
 src/conf/domain_conf.c   |2 +-
 src/conf/domain_conf.h   |1 +
 src/libvirt_private.syms |1 +
 3 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 601dc8b..22be8b9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -887,7 +887,7 @@ void virDomainInputDefFree(virDomainInputDefPtr def)
 VIR_FREE(def);
 }
 
-static void virDomainLeaseDefFree(virDomainLeaseDefPtr def)
+void virDomainLeaseDefFree(virDomainLeaseDefPtr def)
 {
 if (!def)
 return;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 23c1947..9138ea2 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1771,6 +1771,7 @@ bool virDomainObjTaint(virDomainObjPtr obj,
 void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
 void virDomainInputDefFree(virDomainInputDefPtr def);
 void virDomainDiskDefFree(virDomainDiskDefPtr def);
+void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
 void virDomainDiskHostDefFree(virDomainDiskHostDefPtr def);
 int virDomainDiskFindControllerModel(virDomainDefPtr def,
  virDomainDiskDefPtr disk,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 1439d3b..b570922 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -365,6 +365,7 @@ virDomainHubTypeToString;
 virDomainInputDefFree;
 virDomainIoEventFdTypeFromString;
 virDomainIoEventFdTypeToString;
+virDomainLeaseDefFree;
 virDomainLeaseIndex;
 virDomainLeaseInsert;
 virDomainLeaseInsertPreAlloc;
-- 
1.7.7.6

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


[libvirt] [PATCH 4/7] util: eliminate device object leaks related to virDomain*Remove*()

2012-03-08 Thread Laine Stump
There are several functions in domain_conf.c that remove a device
object from the domain's list of that object type, but don't free the
object or return it to the caller to free. In many cases this isn't a
problem because the caller already had a pointer to the object and
frees it afterward, but in several cases the removed object was just
left floating around with no references to it.

In particular, the function qemuDomainDetachDeviceConfig() calls
functions to locate and remove net (virDomainNetRemoveByMac), disk
(virDomainDiskRemoveByName()), and lease (virDomainLeaseRemove())
devices, but neither it nor its caller qemuDomainModifyDeviceConfig()
ever obtain a pointer to the device being removed, much less free it.

This patch modifies the following remove functions to return a
pointer to the device object being removed from the domain device
arrays, to give the caller the option of freeing the device object
using that pointer if needed. In places where the object was
previously leaked, it is now freed:

  virDomainDiskRemove
  virDomainDiskRemoveByName
  virDomainNetRemove
  virDomainNetRemoveByMac
  virDomainHostdevRemove
  virDomainLeaseRemove
  virDomainLeaseRemoveAt

The functions that had been leaking:

  libxlDomainDetachConfig - leaked a virDomainDiskDef
  qemuDomainDetachDeviceConfig - could leak a virDomainDiskDef,
a virDomainNetDef, or a
virDomainLeaseDef
  qemuDomainDetachLease   - leaked a virDomainLeaseDef
---
 src/conf/domain_conf.c   |   48 +
 src/conf/domain_conf.h   |   23 ++---
 src/libxl/libxl_driver.c |5 ++-
 src/qemu/qemu_driver.c   |   15 -
 src/qemu/qemu_hotplug.c  |4 ++-
 5 files changed, 61 insertions(+), 34 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 22be8b9..fd45525 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6856,9 +6856,11 @@ virDomainHostdevInsert(virDomainDefPtr def, 
virDomainHostdevDefPtr hostdev)
 return 0;
 }
 
-void
+virDomainHostdevDefPtr
 virDomainHostdevRemove(virDomainDefPtr def, size_t i)
 {
+virDomainHostdevDefPtr hostdev = def-hostdevs[i];
+
 if (def-nhostdevs  1) {
 memmove(def-hostdevs + i,
 def-hostdevs + i + 1,
@@ -6872,6 +6874,7 @@ virDomainHostdevRemove(virDomainDefPtr def, size_t i)
 VIR_FREE(def-hostdevs);
 def-nhostdevs = 0;
 }
+return hostdev;
 }
 
 /* Find an entry in hostdevs that matches the source spec in
@@ -7035,8 +7038,11 @@ void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
 }
 
 
-void virDomainDiskRemove(virDomainDefPtr def, size_t i)
+virDomainDiskDefPtr
+virDomainDiskRemove(virDomainDefPtr def, size_t i)
 {
+virDomainDiskDefPtr disk = disk = def-disks[i];
+
 if (def-ndisks  1) {
 memmove(def-disks + i,
 def-disks + i + 1,
@@ -7050,15 +7056,16 @@ void virDomainDiskRemove(virDomainDefPtr def, size_t i)
 VIR_FREE(def-disks);
 def-ndisks = 0;
 }
+return disk;
 }
 
-int virDomainDiskRemoveByName(virDomainDefPtr def, const char *name)
+virDomainDiskDefPtr
+virDomainDiskRemoveByName(virDomainDefPtr def, const char *name)
 {
 int i = virDomainDiskIndexByName(def, name, false);
 if (i  0)
-return -1;
-virDomainDiskRemove(def, i);
-return 0;
+return NULL;
+return virDomainDiskRemove(def, i);
 }
 
 int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net)
@@ -7084,7 +7091,8 @@ int virDomainNetIndexByMac(virDomainDefPtr def, const 
unsigned char *mac)
 return -1;
 }
 
-void virDomainNetRemove(virDomainDefPtr def, size_t i)
+virDomainNetDefPtr
+virDomainNetRemove(virDomainDefPtr def, size_t i)
 {
 virDomainNetDefPtr net = def-nets[i];
 
@@ -7115,16 +7123,17 @@ void virDomainNetRemove(virDomainDefPtr def, size_t i)
 VIR_FREE(def-nets);
 def-nnets = 0;
 }
+return net;
 }
 
-int virDomainNetRemoveByMac(virDomainDefPtr def, const unsigned char *mac)
+virDomainNetDefPtr
+virDomainNetRemoveByMac(virDomainDefPtr def, const unsigned char *mac)
 {
 int i = virDomainNetIndexByMac(def, mac);
 
 if (i  0)
-return -1;
-virDomainNetRemove(def, i);
-return 0;
+return NULL;
+return virDomainNetRemove(def, i);
 }
 
 
@@ -7233,8 +7242,12 @@ void virDomainLeaseInsertPreAlloced(virDomainDefPtr def,
 }
 
 
-void virDomainLeaseRemoveAt(virDomainDefPtr def, size_t i)
+virDomainLeaseDefPtr
+virDomainLeaseRemoveAt(virDomainDefPtr def, size_t i)
 {
+
+virDomainLeaseDefPtr lease = def-leases[i];
+
 if (def-nleases  1) {
 memmove(def-leases + i,
 def-leases + i + 1,
@@ -7245,17 +7258,18 @@ void virDomainLeaseRemoveAt(virDomainDefPtr def, size_t 
i)
 VIR_FREE(def-leases);
 def-nleases = 0;
 }
+return lease;
 }
 
 
-int virDomainLeaseRemove(virDomainDefPtr def,
- 

[libvirt] [PATCH 5/7] util: standardize return from functions calling virNetlinkCommand

2012-03-08 Thread Laine Stump
There are several functions that call virNetlinkCommand, and they all
follow a common pattern, with three exit labels: err_exit (or
cleanup), malformed_resp, and buffer_too_small. All three of these
labels do their own cleanup and have their own return. However, the
malformed_resp label usually frees the same items as the
cleanup/err_exit label, and the buffer_too_small label just doesn't
free recvbuf (because it's known to always be NULL at the time we goto
buffer_too_small.

In order to simplify and standardize the code, I've made the following
changes to all of these functions:

1) err_exit is replaced with the more libvirt-ish cleanup, which
   makes sense because in all cases this code is also executed in the
   case of success, so labelling it err_exit may be confusing.

2) rc is initialized to -1, and set to 0 just before the cleanup
   label. Any code that currently sets rc = -1 is made to instead goto
   cleanup.

3) malformed_resp and buffer_too_small just log their error and goto
   cleanup. This gives us a single return path, and a single place to
   free up resources.

4) In one instance, rather then logging an error immediately, a char*
   msg was pointed to an error string, then goto cleanup (and cleanup
   would log an error if msg != NULL). It takes no more lines of code
   to just log the message as we encounter it.

This patch should have 0 functional effects.
---
 src/util/virnetdev.c |   38 
 src/util/virnetdevmacvlan.c  |   37 +---
 src/util/virnetdevvportprofile.c |   87 +-
 3 files changed, 60 insertions(+), 102 deletions(-)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 2cc699a..6eec5cf 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -1249,7 +1249,7 @@ virNetDevLinkDump(const char *ifname, int ifindex,
   unsigned char **recvbuf,
   uint32_t (*getPidFunc)(void))
 {
-int rc = 0;
+int rc = -1;
 struct nlmsghdr *resp;
 struct nlmsgerr *err;
 struct ifinfomsg ifinfo = {
@@ -1284,15 +1284,12 @@ virNetDevLinkDump(const char *ifname, int ifindex,
 if (!nltarget_kernel) {
 pid = getPidFunc();
 if (pid == 0) {
-rc = -1;
 goto cleanup;
 }
 }
 
-if (virNetlinkCommand(nl_msg, recvbuf, recvbuflen, pid)  0) {
-rc = -1;
+if (virNetlinkCommand(nl_msg, recvbuf, recvbuflen, pid)  0)
 goto cleanup;
-}
 
 if (recvbuflen  NLMSG_LENGTH(0) || *recvbuf == NULL)
 goto malformed_resp;
@@ -1309,7 +1306,7 @@ virNetDevLinkDump(const char *ifname, int ifindex,
 virReportSystemError(-err-error,
  _(error dumping %s (%d) interface),
  ifname, ifindex);
-rc = -1;
+goto cleanup;
 }
 break;
 
@@ -1324,29 +1321,22 @@ virNetDevLinkDump(const char *ifname, int ifindex,
 default:
 goto malformed_resp;
 }
-
-if (rc != 0)
-VIR_FREE(*recvbuf);
-
+rc = 0;
 cleanup:
+if (rc  0)
+VIR_FREE(*recvbuf);
 nlmsg_free(nl_msg);
-
 return rc;
 
 malformed_resp:
-nlmsg_free(nl_msg);
-
 virNetDevError(VIR_ERR_INTERNAL_ERROR, %s,
_(malformed netlink response message));
-VIR_FREE(*recvbuf);
-return -1;
+goto cleanup;
 
 buffer_too_small:
-nlmsg_free(nl_msg);
-
 virNetDevError(VIR_ERR_INTERNAL_ERROR, %s,
_(allocated netlink buffer is too small));
-return -1;
+goto cleanup;
 }
 
 static int
@@ -1457,28 +1447,20 @@ virNetDevSetVfConfig(const char *ifname, int ifindex, 
int vf,
 }
 
 rc = 0;
-
 cleanup:
 nlmsg_free(nl_msg);
-
 VIR_FREE(recvbuf);
-
 return rc;
 
 malformed_resp:
-nlmsg_free(nl_msg);
-
 virNetDevError(VIR_ERR_INTERNAL_ERROR, %s,
_(malformed netlink response message));
-VIR_FREE(recvbuf);
-return rc;
+goto cleanup;
 
 buffer_too_small:
-nlmsg_free(nl_msg);
-
 virNetDevError(VIR_ERR_INTERNAL_ERROR, %s,
_(allocated netlink buffer is too small));
-return rc;
+goto cleanup;
 }
 
 static int
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index 647679f..d467990 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -100,7 +100,7 @@ virNetDevMacVLanCreate(const char *ifname,
uint32_t macvlan_mode,
int *retry)
 {
-int rc = 0;
+int rc = -1;
 struct nlmsghdr *resp;
 struct nlmsgerr *err;
 struct ifinfomsg ifinfo = { .ifi_family = AF_UNSPEC };
@@ -155,7 +155,6 @@ virNetDevMacVLanCreate(const char *ifname,
 nla_nest_end(nl_msg, linkinfo);
 
 if (virNetlinkCommand(nl_msg, recvbuf, recvbuflen, 0)  0) {
-rc = -1;
 goto cleanup;
 }
 
@@ -177,14 +176,13 @@ virNetDevMacVLanCreate(const char *ifname,
 
 case 

[libvirt] [PATCH 7/7] qemu: eliminate memory leak in qemuDomainUpdateDeviceConfig

2012-03-08 Thread Laine Stump
This function was freeing a virDomainNetDef with
VIR_FREE(). virDomainNetDef is a complex structure with many pointers
to other dynamically allocated data; to properly free it
virDomainNetDefFree() must be called instead, otherwise several
strings (and potentially other things) will be leaked.
---
 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 32b9386..112266c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5568,7 +5568,7 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
 return -1;
 }
 
-VIR_FREE(vmdef-nets[pos]);
+virDomainNetDefFree(vmdef-nets[pos]);
 
 vmdef-nets[pos] = net;
 dev-data.net = NULL;
-- 
1.7.7.6

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


[libvirt] [PATCH 6/7] qemu: support persistent hotplug of hostdev devices

2012-03-08 Thread Laine Stump
For some reason, although live hotplug of hostdev devices is
supported, persistent hotplug is not. This patch adds the proper
VIR_DOMAIN_DEVICE_HOSTDEV cases to the switches in
qemuDomainAttachDeviceConfig and qemuDomainDetachDeviceConfig.
---
 src/qemu/qemu_driver.c |   32 
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index af89029..32b9386 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5365,6 +5365,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
 {
 virDomainDiskDefPtr disk;
 virDomainNetDefPtr net;
+virDomainHostdevDefPtr hostdev;
 virDomainLeaseDefPtr lease;
 
 switch (dev-type) {
@@ -5406,6 +5407,22 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
 return -1;
 break;
 
+case VIR_DOMAIN_DEVICE_HOSTDEV:
+hostdev = dev-data.hostdev;
+if (virDomainHostdevFind(vmdef, hostdev, NULL) = 0) {
+qemuReportError(VIR_ERR_INVALID_ARG, %s,
+_(device is already in the domain 
configuration));
+return -1;
+}
+if (virDomainHostdevInsert(vmdef, hostdev)) {
+virReportOOMError();
+return -1;
+}
+dev-data.hostdev = NULL;
+if (qemuDomainAssignAddresses(vmdef)  0)
+return -1;
+break;
+
 case VIR_DOMAIN_DEVICE_LEASE:
 lease = dev-data.lease;
 if (virDomainLeaseIndex(vmdef, lease) = 0) {
@@ -5436,6 +5453,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
 {
 virDomainDiskDefPtr disk, det_disk;
 virDomainNetDefPtr net, det_net;
+virDomainHostdevDefPtr hostdev, det_hostdev;
 virDomainLeaseDefPtr lease, det_lease;
 
 switch (dev-type) {
@@ -5462,6 +5480,20 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
 virDomainNetDefFree(det_net);
 break;
 
+case VIR_DOMAIN_DEVICE_HOSTDEV: {
+int idx;
+
+hostdev = dev-data.hostdev;
+if ((idx = virDomainHostdevFind(vmdef, hostdev, det_hostdev))  0) {
+qemuReportError(VIR_ERR_INVALID_ARG, %s,
+_(device not present in domain configuration));
+return -1;
+}
+virDomainHostdevRemove(vmdef, idx);
+virDomainHostdevDefFree(det_hostdev);
+break;
+}
+
 case VIR_DOMAIN_DEVICE_LEASE:
 lease = dev-data.lease;
 if (!(det_lease = virDomainLeaseRemove(vmdef, lease))) {
-- 
1.7.7.6

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


Re: [libvirt] [PATCH] qemu: Don't parse device twice in attach/detach

2012-03-08 Thread Michal Privoznik
On 07.03.2012 19:46, Laine Stump wrote:
 On 03/07/2012 12:48 PM, Michal Privoznik wrote:
 Some nits are generated during XML parse (e.g. MAC address of
 an interface); However, with current implementation, if we
 are plugging a device both to persistent and live config,
 we parse given XML twice: first time for live, second for config.
 This is wrong then as the second time we are not guaranteed
 to generate same values as we did for the first time.
 To prevent that we need to create a copy of DeviceDefPtr;
 This is done through format/parse process instead of writing
 functions for deep copy as it is easier to maintain:
 adding new field to any virDomain*DefPtr doesn't require change
 of copying function.
 ---
 diff to v1:
 -Eric's review included

  src/conf/domain_conf.c   |   70 
 ++
  src/conf/domain_conf.h   |3 ++
  src/libvirt_private.syms |1 +
  src/qemu/qemu_driver.c   |   38 ++---
  4 files changed, 95 insertions(+), 17 deletions(-)

 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
 index b994718..42cfbd5 100644
 --- a/src/conf/domain_conf.c
 +++ b/src/conf/domain_conf.c
 @@ -14529,3 +14529,73 @@ virDomainNetFind(virDomainDefPtr def, const char 
 *device)
  
  return net;
  }
 
 
 I still think there should be a comment added here saying something like:
 
 NB: virDomainDeviceDefCopy does a deep copy of only the parts of a
 DeviceDef that are valid when just the flag VIR_DOMAIN_XML_INACTIVE is
 set. This means that any part of the device xml that is conditionally
 parsed/formatted based on some other flag being set (or on the INACTIVE
 flag being reset) *will not* be copied to the destination. Caveat emptor.
 
 +
 +virDomainDeviceDefPtr
 +virDomainDeviceDefCopy(virCapsPtr caps,
 +   const virDomainDefPtr def,
 +   virDomainDeviceDefPtr src)
 
 
 Otherwise it looks like you've taken care of all of Eric's issues, and
 seems clean, so ACK from me (conditional on adding a comment documenting
 the limitations of the new copy function).

Thank you both; Added comment and pushed.

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

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


[libvirt] [PATCH] util: Don't overflow on errno in virFileAccessibleAs

2012-03-08 Thread Michal Privoznik
If we need to virFork() to check assess() under different
UID+GID we need to translate returned status via WEXITSTATUS().
Otherwise, we may return values greater than 255 which is
obviously wrong.
---
 src/util/util.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/util/util.c b/src/util/util.c
index 548ed1c..15e6cfa 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -724,8 +724,13 @@ virFileAccessibleAs(const char *path, int mode,
 return -1;
 }
 
+if (!WIFEXITED(status)) {
+errno = EINTR;
+return -1;
+}
+
 if (status) {
-errno = status;
+errno = WEXITSTATUS(status);
 return -1;
 }
 
-- 
1.7.8.5

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


[libvirt] [PATCH v2] virsh: Use option alias for outmoded --persistent

2012-03-08 Thread Osier Yang
Since VIR_DOMAIN_AFFECT_{LIVE,CONFIG,CURRENT} was created,
all new virsh commands use --config to represents the
persistent changing. This patch add --config option
for the old commands which still use --persistent,
and --persistent is now alias of --config.

tools/virsh.c: (use --config, and --persistent is
alias of --config now).
cmdDomIfSetLink, cmdDomIfGetLink, cmdAttachDevice,
cmdDetachDevice, cmdUpdateDevice, cmdAttachInterface,
cmdDetachInterface, cmdAttachDisk, cmdDetachDisk

toos/virsh.pod: Update docs of the changed commands, and
add some missed docs for --config (detach-interface,
detach-disk, and detach-device).
---
 tools/virsh.c   |   51 ---
 tools/virsh.pod |   59 --
 2 files changed, 69 insertions(+), 41 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index ee8ff31..9a16ef8 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1643,7 +1643,8 @@ static const vshCmdOptDef opts_domif_setlink[] = {
 {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
 {interface, VSH_OT_DATA, VSH_OFLAG_REQ, N_(interface device (MAC 
Address))},
 {state, VSH_OT_DATA, VSH_OFLAG_REQ, N_(new state of the device)},
-{persistent, VSH_OT_BOOL, 0, N_(persist interface state)},
+{persistent, VSH_OT_ALIAS, 0, config},
+{config, VSH_OT_BOOL, 0, N_(affect next boot)},
 {NULL, 0, 0, NULL}
 };
 
@@ -1658,7 +1659,7 @@ cmdDomIfSetLink (vshControl *ctl, const vshCmd *cmd)
 unsigned char macaddr[VIR_MAC_BUFLEN];
 const char *element;
 const char *attr;
-bool persistent;
+bool config;
 bool ret = false;
 unsigned int flags = 0;
 int i;
@@ -1680,7 +1681,7 @@ cmdDomIfSetLink (vshControl *ctl, const vshCmd *cmd)
 if (vshCommandOptString(cmd, state, state) = 0)
 goto cleanup;
 
-persistent = vshCommandOptBool(cmd, persistent);
+config = vshCommandOptBool(cmd, config);
 
 if (STRNEQ(state, up)  STRNEQ(state, down)) {
 vshError(ctl, _(invalid link state '%s'), state);
@@ -1688,13 +1689,13 @@ cmdDomIfSetLink (vshControl *ctl, const vshCmd *cmd)
 }
 
 /* get persistent or live description of network device */
-desc = virDomainGetXMLDesc(dom, persistent?VIR_DOMAIN_XML_INACTIVE:0);
+desc = virDomainGetXMLDesc(dom, config ? VIR_DOMAIN_XML_INACTIVE : 0);
 if (desc == NULL) {
 vshError(ctl, _(Failed to get domain description xml));
 goto cleanup;
 }
 
-if (persistent)
+if (config)
 flags = VIR_DOMAIN_AFFECT_CONFIG;
 else
 flags = VIR_DOMAIN_AFFECT_LIVE;
@@ -1818,7 +1819,8 @@ static const vshCmdInfo info_domif_getlink[] = {
 static const vshCmdOptDef opts_domif_getlink[] = {
 {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
 {interface, VSH_OT_DATA, VSH_OFLAG_REQ, N_(interface device (MAC 
Address))},
-{persistent, VSH_OT_BOOL, 0, N_(Get persistent interface state)},
+{persistent, VSH_OT_ALIAS, 0, config},
+{config, VSH_OT_BOOL, 0, N_(Get persistent interface state)},
 {NULL, 0, 0, NULL}
 };
 
@@ -1852,7 +1854,7 @@ cmdDomIfGetLink (vshControl *ctl, const vshCmd *cmd)
 return false;
 }
 
-if (vshCommandOptBool(cmd, persistent))
+if (vshCommandOptBool(cmd, config))
 flags = VIR_DOMAIN_XML_INACTIVE;
 
 desc = virDomainGetXMLDesc(dom, flags);
@@ -13460,7 +13462,8 @@ static const vshCmdInfo info_attach_device[] = {
 static const vshCmdOptDef opts_attach_device[] = {
 {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
 {file,   VSH_OT_DATA, VSH_OFLAG_REQ, N_(XML file)},
-{persistent, VSH_OT_BOOL, 0, N_(persist device attachment)},
+{persistent, VSH_OT_ALIAS, 0, config},
+{config, VSH_OT_BOOL, 0, N_(affect next boot)},
 {NULL, 0, 0, NULL}
 };
 
@@ -13490,7 +13493,7 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
 return false;
 }
 
-if (vshCommandOptBool(cmd, persistent)) {
+if (vshCommandOptBool(cmd, config)) {
 flags = VIR_DOMAIN_AFFECT_CONFIG;
 if (virDomainIsActive(dom) == 1)
flags |= VIR_DOMAIN_AFFECT_LIVE;
@@ -13771,7 +13774,8 @@ static const vshCmdInfo info_detach_device[] = {
 static const vshCmdOptDef opts_detach_device[] = {
 {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
 {file,   VSH_OT_DATA, VSH_OFLAG_REQ, N_(XML file)},
-{persistent, VSH_OT_BOOL, 0, N_(persist device detachment)},
+{persistent, VSH_OT_ALIAS, 0, config},
+{config, VSH_OT_BOOL, 0, N_(affect next boot)},
 {NULL, 0, 0, NULL}
 };
 
@@ -13799,7 +13803,7 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
 goto cleanup;
 }
 
-if (vshCommandOptBool(cmd, persistent)) {
+if (vshCommandOptBool(cmd, config)) {
 flags = VIR_DOMAIN_AFFECT_CONFIG;
 if (virDomainIsActive(dom) == 1)
flags |= VIR_DOMAIN_AFFECT_LIVE;
@@ -13835,7 

Re: [libvirt] [PATCH] sanlock: Fix condition left crippled while debugging

2012-03-08 Thread Peter Krempa

On 03/07/2012 05:05 PM, Eric Blake wrote:

On 03/07/2012 07:36 AM, Peter Krempa wrote:

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


ACK.



Pushed; Thanks

Peter

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


Re: [libvirt] [PATCH] sanlock: Use STREQ_NULLABLE instead of STREQ on strings that may be null

2012-03-08 Thread Peter Krempa

On 03/07/2012 05:04 PM, Eric Blake wrote:

On 03/07/2012 07:30 AM, Peter Krempa wrote:

The function sanlock_inquire can return NULL in the state string if the
message consists only of a header. The return value is arbitrary and
sent by the server. We should proceed carefully while touching such
pointers.
---
  src/locking/lock_driver_sanlock.c |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)


ACK.



Pushed; Thanks.

Peter

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


[libvirt] [PATCH v3] qemu: Support numad

2012-03-08 Thread Osier Yang
numad is an user-level daemon that monitors NUMA topology and
processes resource consumption to facilitate good NUMA resource
alignment of applications/virtual machines to improve performance
and minimize cost of remote memory latencies. It provides a
pre-placement advisory interface, so significant processes can
be pre-bound to nodes with sufficient available resources.

More details: http://fedoraproject.org/wiki/Features/numad

numad -w ncpus:memory_amount is the advisory interface numad
provides currently.

This patch add the support by introducing a new XML attribute
for vcpu. e.g.

  vcpu placement=auto4/vcpu
  vcpu placement=static cpuset=1-10^64/vcpu

The returned advisory nodeset from numad will be printed
in domain's dumped XML. e.g.
  vcpu placement=auto cpuset=1-10^64/vcpu

If placement is auto, the number of vcpus and the current
memory amount specified in domain XML will be used for numad
command line (numad uses MB for memory amount):
  numad -w $num_of_vcpus:$current_memory_amount / 1024

The advisory nodeset returned from numad will be used to set
domain process CPU affinity then. (e.g. qemuProcessInitCpuAffinity).

If the user specifies both CPU affinity policy (e.g.
(vcpu cpuset=1-10,^7,^84/vcpu) and placement == auto
the specified CPU affinity will be overridden.

Only QEMU/KVM drivers support it now.

See docs update in patch for more details.

v2 - v3:
  * XML schema is changed to vcpu placement=static|auto4/vcpu
  * Affected tests are updated
  * LXC driver's support is dropped, let's see what's the real
performance on qemu driver first.

v1 - v2:
  * Since Bill Gray says it doesn't matter to use the number of
vcpus and current memory amount as numad cmd line argument,
though from sementics point of view, what numad expects are
physical CPU numbers, let's go this way.
v2 dropped XML cpu required_cpu='4' required_memory='512000'/,
and just a new boolean XML element autonuma. Codes are refactored
accordingly.

  * v1 overrides the cpuset specified by vcpu cpuset='1-10,^7'2/vcpu,
v2 doesn't do that, but just silently ignored.

  * xml2xml test is added
---
 configure.ac   |8 ++
 docs/formatdomain.html.in  |   17 +++-
 docs/schemas/domaincommon.rng  |8 ++
 src/conf/domain_conf.c |  119 ++--
 src/conf/domain_conf.h |   10 ++
 src/libvirt_private.syms   |2 +
 src/qemu/qemu_process.c|   96 ++--
 tests/domainsnapshotxml2xmlout/disk_snapshot.xml   |2 +-
 tests/domainsnapshotxml2xmlout/full_domain.xml |2 +-
 tests/domainsnapshotxml2xmlout/metadata.xml|2 +-
 .../qemuxml2argv-channel-guestfwd.xml  |2 +-
 .../qemuxml2argv-channel-spicevmc-old.xml  |2 +-
 .../qemuxml2argv-channel-spicevmc.xml  |2 +-
 .../qemuxml2argv-channel-virtio-auto.xml   |2 +-
 .../qemuxml2argv-channel-virtio.xml|2 +-
 .../qemuxml2argv-console-virtio-many.xml   |2 +-
 .../qemuxml2argv-console-virtio.xml|2 +-
 tests/qemuxml2argvdata/qemuxml2argv-metadata.xml   |2 +-
 tests/qemuxml2argvdata/qemuxml2argv-minimal.xml|2 +-
 .../qemuxml2argv-seclabel-dynamic-baselabel.xml|2 +-
 .../qemuxml2argv-seclabel-dynamic-override.xml |2 +-
 .../qemuxml2argv-seclabel-dynamic.xml  |2 +-
 .../qemuxml2argv-seclabel-none.xml |2 +-
 .../qemuxml2argv-seclabel-static-relabel.xml   |2 +-
 .../qemuxml2argv-seclabel-static.xml   |2 +-
 .../qemuxml2xmlout-channel-virtio-auto.xml |2 +-
 .../qemuxml2xmlout-console-virtio.xml  |2 +-
 .../qemuxml2xmloutdata/qemuxml2xmlout-metadata.xml |2 +-
 28 files changed, 232 insertions(+), 70 deletions(-)

diff --git a/configure.ac b/configure.ac
index c9cdd7b..31f0835 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1445,6 +1445,14 @@ AM_CONDITIONAL([HAVE_NUMACTL], [test $with_numactl != 
no])
 AC_SUBST([NUMACTL_CFLAGS])
 AC_SUBST([NUMACTL_LIBS])
 
+dnl Do we have numad?
+if test $with_qemu = yes; then
+AC_PATH_PROG([NUMAD], [numad], [], [/bin:/usr/bin:/usr/local/bin:$PATH])
+
+if test -n $NUMAD; then
+AC_DEFINE_UNQUOTED([NUMAD],[$NUMAD], [Location or name of the numad 
program])
+fi
+fi
 
 dnl pcap lib
 LIBPCAP_CONFIG=pcap-config
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 7710c5b..ad7f591 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -318,7 +318,7 @@
 pre
 lt;domaingt;
   ...
-  lt;vcpu cpuset=1-4,^3,6 current=1gt;2lt;/vcpugt;
+  lt;vcpu placement='static' cpuset=1-4,^3,6 current=1gt;2lt;/vcpugt;
   ...
 lt;/domaingt;
 /pre
@@ -336,7 +336,18 @@
 be excluded from a previous range.  span class=sinceSince
 0.8.5/span, the 

Re: [libvirt] [Qemu-devel] Qemu, libvirt, and CPU models

2012-03-08 Thread Lee Schermerhorn
On Wed, 2012-03-07 at 16:07 -0700, Eric Blake wrote:
 On 03/07/2012 03:26 PM, Eduardo Habkost wrote:
  Thanks a lot for the explanations, Daniel.
  
  Comments about specific items inline.
  
 
- How can we make sure there is no confusion between libvirt and Qemu
  about the CPU models? For example, what if cpu_map.xml says model
  'Moo' has the flag 'foo' enabled, but Qemu disagrees? How do we
  guarantee that libvirt gets exactly what it expects from Qemu when
  it asks for a CPU model? We have -cpu ?dump today, but it's not
  the better interface we could have. Do you miss something in special
  in the Qemu-libvirt interface, to help on that?
  
  So, it looks like either I am missing something on my tests or libvirt
  is _not_ probing the Qemu CPU model definitions to make sure libvirt
  gets all the features it expects.
  
  Also, I would like to ask if you have suggestions to implement
  the equivalent of -cpu ?dump in a more friendly and extensible way.
  Would a QMP command be a good alternative? Would a command-line option
  with json output be good enough?
 
 I'm not sure where we are are using -cpu ?dump, but it sounds like we
 should be.
 
  
  (Do we have any case of capability-querying being made using QMP before
  starting any actual VM, today?)
 
 Right now, we have two levels of queries - the 'qemu -help' and 'qemu
 -device ?' output is gathered up front (we really need to patch things
 to cache that, rather than repeating it for every VM start).

Eric:

In addition to VM start, it appears that the libvirt qemu driver also
runs both the 32-bit and 64-bit qemu binaries 3 times each when fetching
capabilities that appears to occur when fetching VM state.  Noticed this
on an openstack/nova compute node that queries vm state periodically.
Seemed to be taking a long time.  stracing libvirtd during these queries
showed this sequence for each query:

6461  17:15:25.269464 execve(/usr/bin/qemu, [/usr/bin/qemu, -cpu, ?], 
[/* 2 vars */]) = 0
6462  17:15:25.335300 execve(/usr/bin/qemu, [/usr/bin/qemu, -help], [/* 2 
vars */]) = 0
6463  17:15:25.393786 execve(/usr/bin/qemu, [/usr/bin/qemu, -device, ?, 
-device, pci-assign,?, -device, virtio-blk-pci,?], [/* 2 vars */]) = 0
6466  17:15:25.841086 execve(/usr/bin/qemu-system-x86_64, 
[/usr/bin/qemu-system-x86_64, -cpu, ?], [/* 2 vars */]) = 0
6468  17:15:25.906746 execve(/usr/bin/qemu-system-x86_64, 
[/usr/bin/qemu-system-x86_64, -help], [/* 2 vars */]) = 0
6469  17:15:25.980520 execve(/usr/bin/qemu-system-x86_64, 
[/usr/bin/qemu-system-x86_64, -device, ?, -device, pci-assign,?, 
-device, virtio-blk-pci,?], [/* 2 vars */]) = 0

Seems to add about a second per VM running on the host.  The periodic
scan thus takes a couple of minutes on a heavily loaded host -- several
10s of VMs.  Not a killer, but we'd like to eliminate it.

I see that libvirt does some level of caching of capabilities, checking
the st_mtime of the binaries to detect changes.  I haven't figured out
when that caching comes into effect, but it doesn't prevent the execs
above.  So, I created a patch series that caches the results of parsing
the output of these calls that I will post shortly for RFC.  It
eliminates most of such execs.  I think it might obviate the existing
capabilities caching, but I'm not sure.  Haven't had time to look into
it.

Later,
Lee Schermerhorn
HPCS


 Then we
 start qemu with -S, query QMP, all before starting the guest (qemu -S is
 in fact necessary for setting some options that cannot be set in the
 current CLI but can be set via the monitor) - but right now that is the
 only point where we query QMP capabilities.
snip

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


Re: [libvirt] [PATCH] util: Don't overflow on errno in virFileAccessibleAs

2012-03-08 Thread Eric Blake
On 03/08/2012 03:37 AM, Michal Privoznik wrote:
 If we need to virFork() to check assess() under different
 UID+GID we need to translate returned status via WEXITSTATUS().
 Otherwise, we may return values greater than 255 which is
 obviously wrong.
 ---
  src/util/util.c |7 ++-
  1 files changed, 6 insertions(+), 1 deletions(-)
 
 diff --git a/src/util/util.c b/src/util/util.c
 index 548ed1c..15e6cfa 100644
 --- a/src/util/util.c
 +++ b/src/util/util.c
 @@ -724,8 +724,13 @@ virFileAccessibleAs(const char *path, int mode,
  return -1;
  }
  
 +if (!WIFEXITED(status)) {
 +errno = EINTR;
 +return -1;
 +}

ACK; this matches what we do in virFileOpenForked.

However, I still see two lingering issues that might be worth revisiting:

1. I wonder if virWaitPid() would be easier to use if it only returned
success on WIFEXITED, and set *status to WEXITSTAUS(), while returning
-1 on any child dying due to a signal.  I'd have to audit the users of
virWaitPid to see if they can all be simplified by this change, or if
there really is a user that needs to know if a child exited due to a signal.

2. This still shares the latent bug in virFileOpenForked that errno is
not always guaranteed to be less than 255; on GNU Hurd, this code is
broken - but libvirt doesn't compile on Hurd.  A true fix would be to
enumerate specific errno values to specific exit codes, and map all
others to a catch-all; see how daemon/libvirtd.c has virDaemonErr for
this purpose.

-- 
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

[libvirt] [PATCH] qemuProcessStart: Switch to flags instead of bunch booleans

2012-03-08 Thread Michal Privoznik
Currently, we have 3 boolean arguments we have to pass
to qemuProcessStart(). As libvirt grows it is harder and harder
to remember them and their position. Therefore we should
switch to flags instead.
---
 src/qemu/qemu_driver.c|   45 +
 src/qemu/qemu_migration.c |7 ---
 src/qemu/qemu_process.c   |   21 +
 src/qemu/qemu_process.h   |   12 
 4 files changed, 54 insertions(+), 31 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d2c4544..1aa3a28 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1326,10 +1326,16 @@ static virDomainPtr qemudDomainCreate(virConnectPtr 
conn, const char *xml,
 virDomainPtr dom = NULL;
 virDomainEventPtr event = NULL;
 virDomainEventPtr event2 = NULL;
+unsigned int start_flags = VIR_QEMU_PROCESS_START_COLD;
 
 virCheckFlags(VIR_DOMAIN_START_PAUSED |
   VIR_DOMAIN_START_AUTODESTROY, NULL);
 
+if (flags  VIR_DOMAIN_START_PAUSED)
+start_flags |= VIR_QEMU_PROCESS_START_PAUSED;
+if (flags  VIR_DOMAIN_START_AUTODESTROY)
+start_flags |= VIR_QEMU_PROCESS_START_AUTODESROY;
+
 qemuDriverLock(driver);
 if (!(def = virDomainDefParseString(driver-caps, xml,
 QEMU_EXPECTED_VIRT_TYPES,
@@ -1358,10 +1364,9 @@ static virDomainPtr qemudDomainCreate(virConnectPtr 
conn, const char *xml,
 if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY)  0)
 goto cleanup; /*  free the 'vm' we created ? */
 
-if (qemuProcessStart(conn, driver, vm, NULL, true,
- (flags  VIR_DOMAIN_START_PAUSED) != 0,
- (flags  VIR_DOMAIN_START_AUTODESTROY) != 0,
- -1, NULL, NULL, VIR_NETDEV_VPORT_PROFILE_OP_CREATE)  
0) {
+if (qemuProcessStart(conn, driver, vm, NULL, -1, NULL, NULL,
+ VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
+ start_flags)  0) {
 virDomainAuditStart(vm, booted, false);
 if (qemuDomainObjEndJob(driver, vm)  0)
 qemuDomainRemoveInactive(driver, vm);
@@ -4109,9 +4114,9 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
 }
 
 /* Set the migration source and start it up. */
-ret = qemuProcessStart(conn, driver, vm, stdio, false, true,
-   false, *fd, path, NULL,
-   VIR_NETDEV_VPORT_PROFILE_OP_RESTORE);
+ret = qemuProcessStart(conn, driver, vm, stdio, *fd, path, NULL,
+   VIR_NETDEV_VPORT_PROFILE_OP_RESTORE,
+   VIR_QEMU_PROCESS_START_PAUSED);
 
 if (intermediatefd != -1) {
 if (ret  0) {
@@ -4681,6 +4686,10 @@ qemuDomainObjStart(virConnectPtr conn,
 bool autodestroy = (flags  VIR_DOMAIN_START_AUTODESTROY) != 0;
 bool bypass_cache = (flags  VIR_DOMAIN_START_BYPASS_CACHE) != 0;
 bool force_boot = (flags  VIR_DOMAIN_START_FORCE_BOOT) != 0;
+unsigned int start_flags = VIR_QEMU_PROCESS_START_COLD;
+
+start_flags |= start_paused ? VIR_QEMU_PROCESS_START_PAUSED : 0;
+start_flags |= autodestroy ? VIR_QEMU_PROCESS_START_AUTODESROY : 0;
 
 /*
  * If there is a managed saved state restore it instead of starting
@@ -4712,9 +4721,8 @@ qemuDomainObjStart(virConnectPtr conn,
 }
 }
 
-ret = qemuProcessStart(conn, driver, vm, NULL, true, start_paused,
-   autodestroy, -1, NULL, NULL,
-   VIR_NETDEV_VPORT_PROFILE_OP_CREATE);
+ret = qemuProcessStart(conn, driver, vm, NULL, -1, NULL, NULL,
+   VIR_NETDEV_VPORT_PROFILE_OP_CREATE, start_flags);
 virDomainAuditStart(vm, booted, ret = 0);
 if (ret = 0) {
 virDomainEventPtr event =
@@ -10795,9 +10803,10 @@ static int 
qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
 if (config)
 virDomainObjAssignDef(vm, config, false);
 
-rc = qemuProcessStart(snapshot-domain-conn, driver, vm, NULL,
-  false, true, false, -1, NULL, snap,
-  VIR_NETDEV_VPORT_PROFILE_OP_CREATE);
+rc = qemuProcessStart(snapshot-domain-conn,
+  driver, vm, NULL, -1, NULL, snap,
+  VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
+  VIR_QEMU_PROCESS_START_PAUSED);
 virDomainAuditStart(vm, from-snapshot, rc = 0);
 detail = VIR_DOMAIN_EVENT_STARTED_FROM_SNAPSHOT;
 event = virDomainEventNewFromObj(vm,
@@ -10882,12 +10891,16 @@ static int 
qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
  VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED)) {
 /* Flush first event, now do transition 2 or 3 */
 bool paused = (flags  VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED) != 0;
+unsigned int 

[libvirt] [PATCH] qemuBuildCommandLine: Don't add tlsPort if none set

2012-03-08 Thread Michal Privoznik
If user hasn't supplied any tlsPort we default to setting it
to zero in our internal structure. However, when building command
line we test it against -1 which is obviously wrong.
---
 src/qemu/qemu_command.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index de2d4a1..ed82cc2 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5374,7 +5374,7 @@ qemuBuildCommandLine(virConnectPtr conn,
 
 virBufferAsprintf(opt, port=%u, def-graphics[0]-data.spice.port);
 
-if (def-graphics[0]-data.spice.tlsPort != -1) {
+if (def-graphics[0]-data.spice.tlsPort) {
 if (!driver-spiceTLS) {
 qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
 _(spice TLS port set in XML configuration,
-- 
1.7.8.5

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


Re: [libvirt] [Qemu-devel] Qemu, libvirt, and CPU models

2012-03-08 Thread Jiri Denemark
On Wed, Mar 07, 2012 at 19:26:25 -0300, Eduardo Habkost wrote:
 Awesome. So, if Qemu and libvirt disagrees, libvirt will know that and
 add the necessary flags? That was my main worry. If disagreement between
 Qemu and libvirt is not a problem, it would make things much easier.
 
 ...but:
 
 Is that really implemented? I simply don't see libvirt doing that. I see
 code that calls -cpu ? to list the available CPU models, but no code
 calling -cpu ?dump, or parsing the Qemu CPU definition config file. I
 even removed some random flags from the Nehalem model on my machine
 (running Fedora 16), and no additional flags were added.

Right, currently we only detect if Qemu knows requested CPU model and use
another one if not. We should really start using something like -cpu ?dump.
However, since qemu may decide to change parts of the model according to,
e.g., machine type, we would need something more dynamic. Something like, hey
Qemu, this is the machine type and CPU model we want to use, these are the
features we want in this model, and we also want few additional features,
please, tell us what the resulting CPU configuration is (if it is even
possible to deliver such CPU on current host). And the result would be
complete CPU model, which may of course be different from what the qemu's
configuration file says. We could then use the result to update domain XML (in
a way similar to how we handle machine types) so that we can guarantee the
guest will always see the same CPU. Once CPU is updated, we could just check
with Qemu if it can provide such CPU and start (or refuse to start) the
domain. Does it seem reasonable?

  We could go one step further and just write
  out a cpu.conf file that we load in QEMU with -loadconfig.
 
 Sounds good. Anyway, I want to make everything configurable on the
 cpudef config file configurable on the command-line too, so both options
 (command-line or config file) would work.

I'd be afraid of hitting the command line length limit if we specified all CPU
details in it :-)

 So, it looks like either I am missing something on my tests or libvirt
 is _not_ probing the Qemu CPU model definitions to make sure libvirt
 gets all the features it expects.
 
 Also, I would like to ask if you have suggestions to implement
 the equivalent of -cpu ?dump in a more friendly and extensible way.
 Would a QMP command be a good alternative? Would a command-line option
 with json output be good enough?

I quite like the possible solution Anthony (or perhaps someone else) suggested
some time ago (it may however be biased by my memory): qemu could provide a
command line option that would take QMP command(s) and the result would be QMP
response on stdout. We could use this interface for all kinds of probes with
easily parsed output.

 (Do we have any case of capability-querying being made using QMP before
 starting any actual VM, today?)

Not really. We only query QMP while for available QMP commands that we can
used further on when the domain is running.

 So, about the above: the cases where libvirt thinks a feature is
 available but Qemu knows it is not available are sort-of OK today,
 because Qemu would simply refuse to start and an error message would be
 returned to the user.

Really? In my experience qemu just ignored the feature it didn't know about
without any error message and started the domain happily. It might be because
libvirt doesn't use anything like -cpu ...,check or whatever is needed to make
it fail. However, I think we should fix it.

 But what about the features that are not available on the host CPU,
 libvirt will think it can't be enabled, but that _can_ be enabled?
 x2apic seems to be the only case today, but we may have others in the
 future.

I think qemu could tell us about those features during the probe phase (my
first paragraph) and we would either use them with policy='force' or something
similar.

Jirka

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


Re: [libvirt] [Qemu-devel] Qemu, libvirt, and CPU models

2012-03-08 Thread Eduardo Habkost
On Wed, Mar 07, 2012 at 04:07:06PM -0700, Eric Blake wrote:
  
  (Do we have any case of capability-querying being made using QMP before
  starting any actual VM, today?)
 
 Right now, we have two levels of queries - the 'qemu -help' and 'qemu
 -device ?' output is gathered up front (we really need to patch things
 to cache that, rather than repeating it for every VM start).

That's what I feared. I was wondering if we had a better
machine-friendly interface to make some of these queries, today.

 Then we
 start qemu with -S, query QMP, all before starting the guest (qemu -S is
 in fact necessary for setting some options that cannot be set in the
 current CLI but can be set via the monitor) - but right now that is the
 only point where we query QMP capabilities.
 
 If QMP can alter the CPU model prior to the initial start of the guest,
 then that would be a sufficient interface.  But I'm worried that once we
 start qemu, even with qemu -S, that it's too late to alter the CPU model
 in use by that guest, and that libvirt should instead start querying
 these things in advance.

This is probably true, and I don't see this being changed in the near
future.

Even if we fix that for CPU initialization, there are many other
initialization steps involved that would have to be reworked to allow
all capability querying to be made to the same Qemu process that would
run the VM later.


 We definitely want a machine-parseable
 construct, so querying over QMP rather than '-cpu ?dump' sounds like it
 might be nicer, but it would also be more work to set up libvirt to do a
 dry-run query of QMP capabilities without also starting a real guest.

On the other hand, with QMP we would have a better interface that could
be used for all other queries libvirt has to run. Instead of running
Qemu multiple times for capability querying, just start a single Qemu
process and make the capability queries using QMP. I don't know if this
was discussed or considered before.


  
  But what about the features that are not available on the host CPU,
  libvirt will think it can't be enabled, but that _can_ be enabled?
  x2apic seems to be the only case today, but we may have others in the
  future.
 
 That's where having an interface to probe qemu to see what capabilities
 are possible for any given cpu model would be worthwhile, so that
 libvirt can correlate the feature sets properly.

Yes. The issue currently is that many things don't depend just on static
CPU model or machine-type definitions, libvirt has to know what
capabilities the kernel provides and Qemu will really be able to use.

It will be a long way to fix this. Some features are simply not
configurable yet, even on the command-line. They are just automatically
used by Qemu when provided by the kernel.

-- 
Eduardo

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


Re: [libvirt] [PATCH] util: Don't overflow on errno in virFileAccessibleAs

2012-03-08 Thread Michal Privoznik
On 08.03.2012 14:08, Eric Blake wrote:
 On 03/08/2012 03:37 AM, Michal Privoznik wrote:
 If we need to virFork() to check assess() under different
 UID+GID we need to translate returned status via WEXITSTATUS().
 Otherwise, we may return values greater than 255 which is
 obviously wrong.
 ---
  src/util/util.c |7 ++-
  1 files changed, 6 insertions(+), 1 deletions(-)

 diff --git a/src/util/util.c b/src/util/util.c
 index 548ed1c..15e6cfa 100644
 --- a/src/util/util.c
 +++ b/src/util/util.c
 @@ -724,8 +724,13 @@ virFileAccessibleAs(const char *path, int mode,
  return -1;
  }
  
 +if (!WIFEXITED(status)) {
 +errno = EINTR;
 +return -1;
 +}
 
 ACK; this matches what we do in virFileOpenForked.

Thanks pushed.
 
 However, I still see two lingering issues that might be worth revisiting:
 
 1. I wonder if virWaitPid() would be easier to use if it only returned
 success on WIFEXITED, and set *status to WEXITSTAUS(), while returning
 -1 on any child dying due to a signal.  I'd have to audit the users of
 virWaitPid to see if they can all be simplified by this change, or if
 there really is a user that needs to know if a child exited due to a signal.

yes, i was wondering about this too when writing the patch. However I
took the quicker way. Let me see if i can produce cleanup patch as
you've described it.
 
 2. This still shares the latent bug in virFileOpenForked that errno is
 not always guaranteed to be less than 255; on GNU Hurd, this code is
 broken - but libvirt doesn't compile on Hurd.  A true fix would be to
 enumerate specific errno values to specific exit codes, and map all
 others to a catch-all; see how daemon/libvirtd.c has virDaemonErr for
 this purpose.
 

Yeah, since we don't compile on Hurd anyway, I wouldn't take much care
here. I am not saying we should make it intentionally harder for a
developer trying to make libvirt compile there, but why unnecessarily
bound ourselves?

Michal

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


Re: [libvirt] [PATCH] xml: Clean up schemas to use shared data types instead of local

2012-03-08 Thread Peter Krempa

On 03/06/2012 04:11 PM, Eric Blake wrote:

On 03/06/2012 08:00 AM, Osier Yang wrote:

On 2012年03月06日 22:15, Peter Krempa wrote:

The schema files contained duplicate data types that can be shared from
the basictypes.rng file.
---




IIRC, unsignedLong allows the the + sign, and leading spaces, which we
may not want.


Actually, unsignedLong does not allow that; see
https://www.redhat.com/archives/libvir-list/2012-March/msg00192.html
which lets the libvirt definition be further restricted:

+define name='unsignedLong'
+data type='unsignedLong'
+param name='pattern'[0-9]+/param
+/data
+/define



Others looks good.


I'm fine with the entire patch, although you probably need to wait to
push it until I've pushed mine (since otherwise basictypes.rng won't
have the unsignedLong definition).


Now that your series is pushed I'll push this. Thanks.

Peter

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

[libvirt] [PATCH] Removed more AMD-specific features from cpu64-rhel* models

2012-03-08 Thread Martin Kletzander
We found few more AMD-specific features in cpu64-rhel* models that
made it impossible to start qemu guest on Intel host (with this
setting) even though qemu itself starts correctly with them.
---
 src/cpu/cpu_map.xml |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index 7ef230e..6a6603b 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -347,7 +347,6 @@
 /model

 model name='cpu64-rhel6'
-  feature name='abm'/
   feature name='apic'/
   feature name='clflush'/
   feature name='cmov'/
@@ -373,7 +372,6 @@
   feature name='sse'/
   feature name='sse2'/
   feature name='pni'/
-  feature name='sse4a'/
   feature name='syscall'/
   feature name='tsc'/
 /model
-- 
1.7.3.4

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


Re: [libvirt] [PATCH] Removed more AMD-specific features from cpu64-rhel* models

2012-03-08 Thread Eric Blake
On 03/08/2012 08:02 AM, Martin Kletzander wrote:
 We found few more AMD-specific features in cpu64-rhel* models that
 made it impossible to start qemu guest on Intel host (with this
 setting) even though qemu itself starts correctly with them.
 ---
  src/cpu/cpu_map.xml |2 --
  1 files changed, 0 insertions(+), 2 deletions(-)
 

 @@ -373,7 +372,6 @@
feature name='sse'/
feature name='sse2'/
feature name='pni'/
 -  feature name='sse4a'/

Should we use this opportunity to sort the remaining feature names?  At
any rate, 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] rpc: Fix VPATH building issue

2012-03-08 Thread Eric Blake
On 03/07/2012 12:45 AM, Guannan Ren wrote:
 Subject: [PATCH] rpc: generalize solution for VPATH builds

 Commit 5d4b0c4c80 tried to fix certain classes of VPATH builds,
 but was too limited.  In particular, Guannan Ren reported:

 For example: The libvirt source code resides in /home/testuser,
  I make dist in /tmp/buildvpath, the XDR routine .c
 file will
  include full path of the header file like:

  #include /home/testuser/src/rpc/virnetprotocol.h
  #include internal.h
  #includearpa/inet.h

 If we distribute the tarball to another machine to compile,
 it will report error as follows:

 rpc/virnetprotocol.c:7:59: fatal error:
 /home/testuser/src/rpc/virnetprotocol.h: No such file or directory

 
 It works great, so ACK here.

Thanks; 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] [libvirt-glib] All string getters should return 'const'

2012-03-08 Thread Christophe Fergeau
Hey,

Thanks for doing this!
I'll do a more in depth review on Monday if noone beats me to it, just some
quick notes:
On Wed, Mar 07, 2012 at 06:02:06AM +0200, Zeeshan Ali (Khattak) wrote:
 From: Zeeshan Ali (Khattak) zeesha...@gnome.org
 -char *
 -gvir_config_xml_get_child_element_content_glib (xmlNode*node,
 +const char *
 +gvir_config_xml_get_child_element_content_glib (xmlNode *node,
  const char *child_name)
  {
 -xmlChar *content;
 +const xmlChar *content;
  
 -content = gvir_config_xml_get_child_element_content (node, 
 child_name);
 +content = gvir_config_xml_get_child_element_content(node, child_name);
  
 -return libxml_str_to_glib(content);
 +return (const char *)content;
  }

Not really useful to have a function whose only use is doing a cast for us,
I'd kill it and have get_child_element_content return a char *. For
functions which take a xmlChar *, cast it to char * and then return it, it
may be better to use BAD_CAST to do the cast (
http://xmlsoft.org/html/libxml-xmlstring.html#BAD_CAST ) so that we can
easily spot these functions if we need to some day.

  
 -G_GNUC_INTERNAL xmlChar *
 +G_GNUC_INTERNAL const xmlChar *
  gvir_config_xml_get_attribute_content(xmlNodePtr node, const char *attr_name)
  {
 -return xmlGetProp(node, (const xmlChar*)attr_name);
 +xmlAttr *attr;
 +
 +for (attr = node-properties; attr; attr = attr-next) {
 +if (attr-name == NULL)
 +continue;
 +
 +if (strcmp (attr_name, (char *)attr-name) == 0)
 +break;
 +}
 +
 +return attr-children-content;
  }
  
 -G_GNUC_INTERNAL char *
 +G_GNUC_INTERNAL const char *
  gvir_config_xml_get_attribute_content_glib(xmlNodePtr node, const char 
 *attr_name)
  {
 -xmlChar *attr;
 +const xmlChar *attr;
  
  attr = gvir_config_xml_get_attribute_content(node, attr_name);
  
 -return libxml_str_to_glib(attr);
 +return (const char *) attr;
  }

Can be killed too.

  
  const char *gvir_config_genum_get_nick (GType enum_type, gint value)
 diff --git a/libvirt-gconfig/libvirt-gconfig-object-private.h 
 b/libvirt-gconfig/libvirt-gconfig-object-private.h
 index 41cbfe8..a6b7395 100644
 --- a/libvirt-gconfig/libvirt-gconfig-object-private.h
 +++ b/libvirt-gconfig/libvirt-gconfig-object-private.h
 @@ -31,17 +31,17 @@ GVirConfigObject *gvir_config_object_new_from_tree(GType 
 type,
 const char *schema,
 xmlNodePtr tree);
  xmlNodePtr gvir_config_object_get_xml_node(GVirConfigObject *config);
 -char *gvir_config_object_get_node_content(GVirConfigObject *object,
 -  const char *node_name);
 +const char *gvir_config_object_get_node_content(GVirConfigObject *object,
 +const char *node_name);
  guint64 gvir_config_object_get_node_content_uint64(GVirConfigObject *object,
 const char *node_name);
  gint gvir_config_object_get_node_content_genum(GVirConfigObject *object,
 const char *node_name,
 GType enum_type,
 gint default_value);
 -char *gvir_config_object_get_attribute(GVirConfigObject *object,
 -   const char *node_name,
 -   const char *attr_name);
 +const char *gvir_config_object_get_attribute(GVirConfigObject *object,
 + const char *node_name,
 + const char *attr_name);
  gint gvir_config_object_get_attribute_genum(GVirConfigObject *object,
  const char *node_name,
  const char *attr_name,
 diff --git a/libvirt-gconfig/libvirt-gconfig-object.c 
 b/libvirt-gconfig/libvirt-gconfig-object.c
 index b637960..d99a0a2 100644
 --- a/libvirt-gconfig/libvirt-gconfig-object.c
 +++ b/libvirt-gconfig/libvirt-gconfig-object.c
 @@ -274,7 +274,7 @@ gvir_config_object_get_xml_node(GVirConfigObject *config)
  return config-priv-node;
  }
  
 -G_GNUC_INTERNAL char *
 +G_GNUC_INTERNAL const char *
  gvir_config_object_get_node_content(GVirConfigObject *object,
  const char *node_name)
  {
 @@ -287,7 +287,7 @@ gvir_config_object_get_node_content(GVirConfigObject 
 *object,
  return gvir_config_xml_get_child_element_content_glib(node, node_name);
  }
  
 -G_GNUC_INTERNAL char *
 +G_GNUC_INTERNAL const char *
  gvir_config_object_get_attribute(GVirConfigObject *object,
   const char *node_name,
   const char *attr_name)
 @@ -559,7 +559,7 @@ 
 

Re: [libvirt] [libvirt-glib] Keep domain devices list sorted

2012-03-08 Thread Christophe Fergeau
On Wed, Mar 07, 2012 at 01:56:44AM +0200, Zeeshan Ali (Khattak) wrote:
 On Wed, Mar 7, 2012 at 1:03 AM, Eric Blake ebl...@redhat.com wrote:
  Actually, if I understand things right, preserving order _is_ important
  to guarantee.  For example, with older XML that lacked per-device boot
  order='n'/, libvirt would determine which order devices are presented
  to guest BIOS boot order based on their position within XML.
 
 Well, I agree. You only need to convince Christophe on this. :)

If there's a compelling reason for keeping it, which Eric just
demonstrated, I'm all for keeping the order. All I was saying is that
without such a reason, I don't think it's worth going out of our way to
keep it, and that not guarateeing it's kept gives us more flexibility if
needed.
Since it's actually important to keep thing ordered, case is closed.

Christophe


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

Re: [libvirt] Can't connect ESXi ssl with virsh

2012-03-08 Thread Matthias Bolte
2012/3/5 Zhimou Peng zhp...@redhat.com:
 Hi,

 I try to use virsh connect ESXi5.0 with ssl

 [root@zheng ~]#  virsh -c esx://10.66.6.211/
 Enter username for 10.66.6.211 [root]:
 Enter root's password for 10.66.6.211:
 error: internal error curl_easy_perform() returned an error: Peer certificate 
 cannot be authenticated with known CA certificates (60) : Peer certificate 
 cannot be authenticated with known CA certificates
 error: failed to connect to the hypervisor

 I create kew key singed by my CA certificate, still the same error.
 But i can use vsphere client and https://10.66.6.211/, the new certs are ok.

 Here are my steps:


 1, create a CA center.

 ENV prepare:
 # cd /etc/pki/CA/
 # mkdir {certs,crl,newcerts}
 # touch index.txt
 # echo 00  serial

 create private key:
 [root@zheng CA]# openssl req -new -x509 -extensions v3_ca -keyout myroot.key 
 -out myroot.crt -days 3650
 Generating a 2048 bit RSA private key
 +++
 ...+++
 writing new private key to 'myroot.key'
 Enter PEM pass phrase:
 Verifying - Enter PEM pass phrase:
 -
 You are about to be asked to enter information that will be incorporated
 into your certificate request.
 What you are about to enter is what is called a Distinguished Name or a DN.
 There are quite a few fields but you can leave some blank
 For some fields there will be a default value,
 If you enter '.', the field will be left blank.
 -
 Country Name (2 letter code) [XX]:CN
 State or Province Name (full name) []:BEIJING
 Locality Name (eg, city) [Default City]:BEIJING
 Organization Name (eg, company) [Default Company Ltd]:REDHAT
 Organizational Unit Name (eg, section) []:QE
 Common Name (eg, your name or your server's hostname) []:10.66.6.209
 Email Address []:

 [root@zheng CA]# mv myroot.key private/cakey.pem
 [root@zheng CA]# mv myroot.crt cacert.pem

 2, create private key and certificate request file for ESXi5.0 server.
 # openssl req -new -nodes -out mycsr.csr
 Generating a 2048 bit RSA private key
 +++
 ...+++
 writing new private key to 'privkey.pem'
 -
 You are about to be asked to enter information that will be incorporated
 into your certificate request.
 What you are about to enter is what is called a Distinguished Name or a DN.
 There are quite a few fields but you can leave some blank
 For some fields there will be a default value,
 If you enter '.', the field will be left blank.
 -
 Country Name (2 letter code) [XX]:CN
 State or Province Name (full name) []:BEIJING
 Locality Name (eg, city) [Default City]:BEIJING
 Organization Name (eg, company) [Default Company Ltd]:REDHAT
 Organizational Unit Name (eg, section) []:QE
 Common Name (eg, your name or your server's hostname) []:10.66.6.211
 Email Address []:

 Please enter the following 'extra' attributes
 to be sent with your certificate request
 A challenge password []:
 An optional company name []:

 3,scp the certificate request file to CA and certificate it.
 [root@zheng CA]# openssl ca -out rui.crt  -infiles mycsr.csr
 Using configuration from /etc/pki/tls/openssl.cnf
 Enter pass phrase for /etc/pki/CA/private/cakey.pem:
 Check that the request matches the signature
 Signature ok
 Certificate Details:
        Serial Number: 0 (0x0)
        Validity
            Not Before: Mar  5 06:53:52 2012 GMT
            Not After : Mar  5 06:53:52 2013 GMT
        Subject:
            countryName               = CN
            stateOrProvinceName       = BEIJING
            organizationName          = REDHAT
            organizationalUnitName    = QE
            commonName                = 10.66.6.211
        X509v3 extensions:
            X509v3 Basic Constraints:
                CA:FALSE
            Netscape Comment:
                OpenSSL Generated Certificate
            X509v3 Subject Key Identifier:
                84:ED:53:00:56:7B:F3:AD:69:70:44:8C:D3:09:A0:6E:9D:69:30:0A
            X509v3 Authority Key Identifier:
                
 keyid:E5:FC:AC:8B:C4:6E:DD:DF:32:19:E3:C1:17:3E:08:5B:7D:0D:79:DD

 Certificate is to be certified until Mar  5 06:53:52 2013 GMT (365 days)
 Sign the certificate? [y/n]:y


 1 out of 1 certificate requests certified, commit? [y/n]y
 Write out database with 1 new entries
 Data Base Updated

 4, change the ESXi to maintance mode and change ssl keys on /etc/vmware/ssl. 
 restart hostd server
   then quit the maintance mode.

Until here everything is fine. The ESXi server has a new and working
SSL certificate.

 5, test it with vsphere client and firefox. new ssl keys works well.

You should have tested with curl instead, because libvirt uses libcurl
to talk to the ESXi server.

# curl https://10.66.6.211/sdk
curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate
verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html

And curl still 

[libvirt] libvirt_tck autotest wrapper looks good, commited

2012-03-08 Thread Lucas Meneghel Rodrigues

Thanks Guannan:

https://github.com/autotest/autotest/commit/ba4b748e7b9a9bfe7898a97cdccdc9b867d5321c

Cheers,

Lucas

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


Re: [libvirt] Build error on OSX in src/util/virnetlink.c

2012-03-08 Thread Laine Stump
On 03/06/2012 11:28 AM, Eric Blake wrote:
 On 03/06/2012 09:15 AM, Duncan Rance wrote:
 Hi,

 I'm building on OSX with no libnl. I had to do this to get 
 src/util/virnetlink.c to compile:



 diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
 index 1575bad..59f3e39 100644
 --- a/src/util/virnetlink.c
 +++ b/src/util/virnetlink.c
 @@ -545,9 +545,9 @@ int virNetlinkCommand(struct nl_msg *nl_msg 
 ATTRIBUTE_UNUSED,
   */
  int virNetlinkEventServiceStop(void)
  {
 +# if defined(__linux__)  !defined(HAVE_LIBNL)
  netlinkError(VIR_ERR_INTERNAL_ERROR,
  %s,
 -# if defined(__linux__)  !defined(HAVE_LIBNL)
  _(virNetlinkEventServiceStop is not supported since libnl 
 was not available));
 Oops - that's a blatant bug.  ACK and pushed.  I've also added you to
 AUTHORS; let me know if you prefer an alternate spelling.

That fix is actually a bit off - it ends up emitting no error log on
failure for non-linux systems. (Of course these functions should never
even be called on non-linux systems, so the difference is mostly
academic :-)

I made a more comprehensive patch for all the stub functions in
virnetlink.c that collapses all of the nearly-identical log messages and
eliminates the use of preprocessor directives within macro invocations
for those functions:

  https://www.redhat.com/archives/libvir-list/2012-March/msg00316.html

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


Re: [libvirt] [PATCH 1/7] util: consolidate duplicated error messages in virnetlink.c

2012-03-08 Thread Eric Blake
On 03/08/2012 02:24 AM, Laine Stump wrote:
 There are special stub versions of all public functions in this file
 that are compiled when either libnl isn't available or the platform
 isn't linux. Each of these functions had two almost identical message,
 differing only in the function name included in the message. Since log
 messages already contain the function name, we can just define a const
 char* with the common part of the string, and use that same string for
 all the log messages.
 
 Also, rather than doing #if defined ... #else ... #endif *inside the
 error log macro invocation*, this patch does #if defined ... just
 once, using it to decide which single string to define. This turns the
 error log in each function from 6 lines, to 1 line.
 ---
  src/util/virnetlink.c |   47 ---
  1 files changed, 12 insertions(+), 35 deletions(-)
 
 diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
 index 59f3e39..77dde9f 100644
 --- a/src/util/virnetlink.c
 +++ b/src/util/virnetlink.c
 @@ -525,17 +525,18 @@ cleanup:
  
  #else

This else matches up to an earlier:

#if defined(__linux__)  defined(HAVE_LIBNL)

  
 +# if defined(__linux)  !defined(HAVE_LIBNL)

Which means the  !defined(HAVE_LIBNL) is redundant here; you could
simplify to:

# ifdef __linux

and get the same results.

 +static const char *unsupported = _(libnl was not available at build time);
 +# else
 +static const char *unsupported = _(not supported on non-linux platforms);
 +# endif

GCC correctly complains that the initializer is not a constant.  This
needs to be N_()...

 +netlinkError(VIR_ERR_INTERNAL_ERROR, %s, unsupported);

and all of these changed to _(unsupported).

ACK to the idea, once you fix the compilation errors that you get on
non-Linux or with HAVE_LIBNL forcefully undefined in config.h.

-- 
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 0/7] Various bugfixes related to device management

2012-03-08 Thread Eric Blake
On 03/08/2012 02:24 AM, Laine Stump wrote:
 This series contains 7 patches that are mostly related by the face
 that I noticed the problems they're solving while writing the
 interface type='hostdev' code during the past couple weeks. After
 that series was pushed, I sat down to fix everything I'd noticed
 before I forgot about it. I'm sending it as a single series rather
 than individual patches just to that they're easier to keep track of.

ACK series, once you fix the problems in 1/7.

-- 
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] Attach vm-id to Open vSwitch interfaces.

2012-03-08 Thread Laine Stump
On 03/07/2012 02:15 AM, Ansis Atteka wrote:
 This patch will allow OpenFlow controllers to identify which interface
 belongs to a particular VM by using the Domain UUID.

 ovs-vsctl get Interface vnet0 external_ids
 {attached-mac=52:54:00:8C:55:2C, 
 iface-id=83ce45d6-3639-096e-ab3c-21f66a05f7fa, iface-status=active, 
 vm-id=142a90a7-0acc-ab92-511c-586f12da8851}

 V2 changes:
 Replaced vm-uuid with vm-id. There was a discussion in Open vSwitch
 mailinglist that we should stick with the same DB key postfixes for the
 sake of consistency (e.g iface-id, vm-id ...).

This all looks good, and simply adding the vmuuid argument to the
callchain that goes down to virNetDevOpenvswitchAddPort seems like the
simplest, most consistent way to get the information down to that function.

ACK, and pushed.


 ---
  src/lxc/lxc_driver.c|3 ++-
  src/network/bridge_driver.c |2 +-
  src/qemu/qemu_command.c |3 ++-
  src/uml/uml_conf.c  |3 ++-
  src/util/virnetdevopenvswitch.c |   17 ++---
  src/util/virnetdevopenvswitch.h |1 +
  src/util/virnetdevtap.c |3 ++-
  src/util/virnetdevtap.h |1 +
  8 files changed, 25 insertions(+), 8 deletions(-)



  external-ids:iface-status=active,
 @@ -100,6 +110,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, const 
 char *ifname,
  cleanup:
  VIR_FREE(attachedmac_ex_id);
  VIR_FREE(ifaceid_ex_id);
 +VIR_FREE(vmid_ex_id);
  VIR_FREE(profile_ex_id);
  virCommandFree(cmd);
  return ret;

Hmm. I just now noticed the odd indentation here. I'll take care of that
in a separate small patch.

I'm also sending a patch to call virReportOOMError() when the
virAsprintf() calls in that function fail.

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


[libvirt] [PATCH] util: whitespace change to virNetDevOpenvswitchAddPort

2012-03-08 Thread Laine Stump
The indentation on the final lines of the function was off by four
spaces, making me wonder for a second if there was something
missing. (There wasn't.)
---

Pushing under trivial rule.

 src/util/virnetdevopenvswitch.c |   14 +++---
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index e427c94..9d6d924 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -95,14 +95,14 @@ int virNetDevOpenvswitchAddPort(const char *brname, const 
char *ifname,
  ifname, brname);
 goto cleanup;
 }
-ret = 0;
 
-cleanup:
-VIR_FREE(attachedmac_ex_id);
-VIR_FREE(ifaceid_ex_id);
-VIR_FREE(profile_ex_id);
-virCommandFree(cmd);
-return ret;
+ret = 0;
+cleanup:
+VIR_FREE(attachedmac_ex_id);
+VIR_FREE(ifaceid_ex_id);
+VIR_FREE(profile_ex_id);
+virCommandFree(cmd);
+return ret;
 }
 
 /**
-- 
1.7.7.6

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


Re: [libvirt] [PATCH] util: log error on OOM in virNetDevOpenvswitchAddPort

2012-03-08 Thread Eric Blake
On 03/08/2012 11:58 AM, Laine Stump wrote:
 OOM conditions silently returned failure.
 ---
  src/util/virnetdevopenvswitch.c |   12 
  1 files changed, 8 insertions(+), 4 deletions(-)
 
 diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
 index e2d5124..61bb9e1 100644
 --- a/src/util/virnetdevopenvswitch.c
 +++ b/src/util/virnetdevopenvswitch.c
 @@ -64,17 +64,17 @@ int virNetDevOpenvswitchAddPort(const char *brname, const 
 char *ifname,
  
  if (virAsprintf(attachedmac_ex_id, external-ids:attached-mac=\%s\,
  macaddrstr)  0)
 -goto cleanup;
 +goto out_of_memory;

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

[libvirt] [PATCH] util: log error on OOM in virNetDevOpenvswitchAddPort

2012-03-08 Thread Laine Stump
OOM conditions silently returned failure.
---
 src/util/virnetdevopenvswitch.c |   12 
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index e2d5124..61bb9e1 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -64,17 +64,17 @@ int virNetDevOpenvswitchAddPort(const char *brname, const 
char *ifname,
 
 if (virAsprintf(attachedmac_ex_id, external-ids:attached-mac=\%s\,
 macaddrstr)  0)
-goto cleanup;
+goto out_of_memory;
 if (virAsprintf(ifaceid_ex_id, external-ids:iface-id=\%s\,
 ifuuidstr)  0)
-goto cleanup;
+goto out_of_memory;
 if (virAsprintf(vmid_ex_id, external-ids:vm-id=\%s\,
 vmuuidstr)  0)
-goto cleanup;
+goto out_of_memory;
 if (ovsport-u.openvswitch.profileID[0] != '\0') {
 if (virAsprintf(profile_ex_id, external-ids:port-profile=\%s\,
 ovsport-u.openvswitch.profileID)  0)
-goto cleanup;
+goto out_of_memory;
 }
 
 cmd = virCommandNew(OVSVSCTL);
@@ -114,6 +114,10 @@ cleanup:
 VIR_FREE(profile_ex_id);
 virCommandFree(cmd);
 return ret;
+
+out_of_memory:
+virReportOOMError();
+goto cleanup;
 }
 
 /**
-- 
1.7.7.6

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


[libvirt] [PATCH] util: add stub pciConfigAddressToSysfsFile for non-linux platforms

2012-03-08 Thread Laine Stump
Absence of this stub function caused a build failure on mingw32.
---

Pushed under build breaker rule (I'm doing way too many of these - I
really need to start running autobuild before any push, instead of
just make check  make syntax-check.)

 src/util/pci.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/util/pci.c b/src/util/pci.c
index a6212f2..e7bfb92 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -2209,6 +2209,15 @@ pciGetVirtualFunctionIndex(const char 
*pf_sysfs_device_link ATTRIBUTE_UNUSED,
 }
 
 int
+pciConfigAddressToSysfsFile(struct pci_config_address *dev ATTRIBUTE_UNUSED,
+char **pci_sysfs_device_link ATTRIBUTE_UNUSED)
+{
+pciReportError(VIR_ERR_INTERNAL_ERROR, _(pciConfigAddressToSysfsFile is 
not 
+   supported on non-linux platforms));
+return -1;
+}
+
+int
 pciDeviceNetName(char *device_link_sysfs_path ATTRIBUTE_UNUSED,
  char **netname ATTRIBUTE_UNUSED)
 {
-- 
1.7.7.6

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


[libvirt] [PATCH] remove daemon/probes.h from .gitignore

2012-03-08 Thread Laine Stump
The file daemon/probes.h used to be generated as part of a build, but
is no longer used. However, a stale copy of it lying around could
cause a build to fail. Removing it from .gitignore will make it more
likely someone will notice that they have it lying around.
---

Although this is a very simple change, I haven't used the trivial rule
to push it, just to make sure everyone notices it, and nobody
accidentally adds the file to git with git add ..

 .gitignore |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/.gitignore b/.gitignore
index 264a419..b35e863 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,7 +54,6 @@
 /daemon/libvirtd.8
 /daemon/libvirtd.8.in
 /daemon/libvirtd.pod
-/daemon/probes.h
 /docs/devhelp/libvirt.devhelp
 /docs/hvsupport.html.in
 /docs/libvirt-api.xml
-- 
1.7.7.6

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


[libvirt] [PATCH] util: consolidate duplicated error messages in pci.c

2012-03-08 Thread Laine Stump
This is nearly identical to an earlier patch for virnetlink.c (after
fixing it per Eric's recommendations).

There are special stub versions of all public functions in this file
that are compiled when the platform isn't linux. Each of these
functions had an almost identical message, differing only in the
function name included in the message. Since log messages already
contain the function name, we can just define a const char* with the
common part of the string, and use that same string for all the log
messages.

If nothing else, this at least makes for less strings that need
translating...
---
 src/util/pci.c |   23 +--
 1 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/src/util/pci.c b/src/util/pci.c
index e7bfb92..7beeaee 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -2170,12 +2170,13 @@ cleanup:
 }
 
 #else
+static const char *unsupported = N_(not supported on non-linux platforms);
+
 int
 pciGetPhysicalFunction(const char *vf_sysfs_path ATTRIBUTE_UNUSED,
   struct pci_config_address **physical_function ATTRIBUTE_UNUSED)
 {
-pciReportError(VIR_ERR_INTERNAL_ERROR, _(pciGetPhysicalFunction is not 
-   supported on non-linux platforms));
+pciReportError(VIR_ERR_INTERNAL_ERROR, %s, _(unsupported));
 return -1;
 }
 
@@ -2184,16 +2185,14 @@ pciGetVirtualFunctions(const char *sysfs_path 
ATTRIBUTE_UNUSED,
  struct pci_config_address ***virtual_functions ATTRIBUTE_UNUSED,
  unsigned int *num_virtual_functions ATTRIBUTE_UNUSED)
 {
-pciReportError(VIR_ERR_INTERNAL_ERROR, _(pciGetVirtualFunctions is not 
-   supported on non-linux platforms));
+pciReportError(VIR_ERR_INTERNAL_ERROR, %s, _(unsupported));
 return -1;
 }
 
 int
 pciDeviceIsVirtualFunction(const char *vf_sysfs_device_link ATTRIBUTE_UNUSED)
 {
-pciReportError(VIR_ERR_INTERNAL_ERROR, _(pciDeviceIsVirtualFunction is 
-   not supported on non-linux platforms));
+pciReportError(VIR_ERR_INTERNAL_ERROR, %s, _(unsupported));
 return -1;
 }
 
@@ -2202,8 +2201,7 @@ pciGetVirtualFunctionIndex(const char 
*pf_sysfs_device_link ATTRIBUTE_UNUSED,
const char *vf_sysfs_device_link ATTRIBUTE_UNUSED,
int *vf_index ATTRIBUTE_UNUSED)
 {
-pciReportError(VIR_ERR_INTERNAL_ERROR, _(pciGetVirtualFunctionIndex is 
-   not supported on non-linux platforms));
+pciReportError(VIR_ERR_INTERNAL_ERROR, %s, _(unsupported));
 return -1;
 
 }
@@ -2212,8 +2210,7 @@ int
 pciConfigAddressToSysfsFile(struct pci_config_address *dev ATTRIBUTE_UNUSED,
 char **pci_sysfs_device_link ATTRIBUTE_UNUSED)
 {
-pciReportError(VIR_ERR_INTERNAL_ERROR, _(pciConfigAddressToSysfsFile is 
not 
-   supported on non-linux platforms));
+pciReportError(VIR_ERR_INTERNAL_ERROR, %s, _(unsupported));
 return -1;
 }
 
@@ -2221,8 +2218,7 @@ int
 pciDeviceNetName(char *device_link_sysfs_path ATTRIBUTE_UNUSED,
  char **netname ATTRIBUTE_UNUSED)
 {
-pciReportError(VIR_ERR_INTERNAL_ERROR, _(pciDeviceNetName is not 
-   supported on non-linux platforms));
+pciReportError(VIR_ERR_INTERNAL_ERROR, %s, _(unsupported));
 return -1;
 }
 
@@ -2231,8 +2227,7 @@ pciDeviceGetVirtualFunctionInfo(const char 
*vf_sysfs_device_path ATTRIBUTE_UNUSE
 char **pfname ATTRIBUTE_UNUSED,
 int *vf_index ATTRIBUTE_UNUSED)
 {
-pciReportError(VIR_ERR_INTERNAL_ERROR, _(pciDeviceGetVirtualFunctionInfo 
-   is not supported on non-linux platforms));
+pciReportError(VIR_ERR_INTERNAL_ERROR, %s, _(unsupported));
 return -1;
 }
 #endif /* __linux__ */
-- 
1.7.7.6

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


Re: [libvirt] [PATCH] util: consolidate duplicated error messages in pci.c

2012-03-08 Thread Eric Blake
On 03/08/2012 02:53 PM, Laine Stump wrote:
 This is nearly identical to an earlier patch for virnetlink.c (after
 fixing it per Eric's recommendations).
 
 There are special stub versions of all public functions in this file
 that are compiled when the platform isn't linux. Each of these
 functions had an almost identical message, differing only in the
 function name included in the message. Since log messages already
 contain the function name, we can just define a const char* with the
 common part of the string, and use that same string for all the log
 messages.
 
 If nothing else, this at least makes for less strings that need
 translating...
 ---
  src/util/pci.c |   23 +--
  1 files changed, 9 insertions(+), 14 deletions(-)

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] remove daemon/probes.h from .gitignore

2012-03-08 Thread Eric Blake
On 03/08/2012 02:53 PM, Laine Stump wrote:
 The file daemon/probes.h used to be generated as part of a build, but
 is no longer used. However, a stale copy of it lying around could
 cause a build to fail. Removing it from .gitignore will make it more
 likely someone will notice that they have it lying around.
 ---
 
 Although this is a very simple change, I haven't used the trivial rule
 to push it, just to make sure everyone notices it, and nobody
 accidentally adds the file to git with git add ..

If you have a long-lived tree, or plan on swapping to old commits prior
to the point where we renamed things, I recommend doing:

echo /daemon/probes.h  .git/info/exclude

then you will be immune from 'git add .' accidentally re-adding it.

Fresh checkouts are immune, and with this message serving as notice, I
think we're okay.

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 0/7] Various bugfixes related to device management

2012-03-08 Thread Laine Stump
On 03/08/2012 01:41 PM, Eric Blake wrote:
 On 03/08/2012 02:24 AM, Laine Stump wrote:
 This series contains 7 patches that are mostly related by the face
 that I noticed the problems they're solving while writing the
 interface type='hostdev' code during the past couple weeks. After
 that series was pushed, I sat down to fix everything I'd noticed
 before I forgot about it. I'm sending it as a single series rather
 than individual patches just to that they're easier to keep track of.
 ACK series, once you fix the problems in 1/7.



Okay, I pushed them all (after making the changes you suggested, and
running autobuild.sh successfully). Thanks!

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


Re: [libvirt] [PATCH] util: log error on OOM in virNetDevOpenvswitchAddPort

2012-03-08 Thread Laine Stump
On 03/08/2012 02:00 PM, Eric Blake wrote:
 On 03/08/2012 11:58 AM, Laine Stump wrote:
 OOM conditions silently returned failure.
 ---
  src/util/virnetdevopenvswitch.c |   12 
  1 files changed, 8 insertions(+), 4 deletions(-)

 diff --git a/src/util/virnetdevopenvswitch.c 
 b/src/util/virnetdevopenvswitch.c
 index e2d5124..61bb9e1 100644
 --- a/src/util/virnetdevopenvswitch.c
 +++ b/src/util/virnetdevopenvswitch.c
 @@ -64,17 +64,17 @@ int virNetDevOpenvswitchAddPort(const char *brname, 
 const char *ifname,
  
  if (virAsprintf(attachedmac_ex_id, external-ids:attached-mac=\%s\,
  macaddrstr)  0)
 -goto cleanup;
 +goto out_of_memory;
 ACK.

Pushed. Thanks!

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


Re: [libvirt] [PATCH] util: consolidate duplicated error messages in pci.c

2012-03-08 Thread Laine Stump
On 03/08/2012 04:57 PM, Eric Blake wrote:
 On 03/08/2012 02:53 PM, Laine Stump wrote:
 This is nearly identical to an earlier patch for virnetlink.c (after
 fixing it per Eric's recommendations).

 There are special stub versions of all public functions in this file
 that are compiled when the platform isn't linux. Each of these
 functions had an almost identical message, differing only in the
 function name included in the message. Since log messages already
 contain the function name, we can just define a const char* with the
 common part of the string, and use that same string for all the log
 messages.

 If nothing else, this at least makes for less strings that need
 translating...
 ---
  src/util/pci.c |   23 +--
  1 files changed, 9 insertions(+), 14 deletions(-)
 ACK.

Pushed.

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


Re: [libvirt] [PATCH] remove daemon/probes.h from .gitignore

2012-03-08 Thread Laine Stump
On 03/08/2012 04:59 PM, Eric Blake wrote:
 On 03/08/2012 02:53 PM, Laine Stump wrote:
 The file daemon/probes.h used to be generated as part of a build, but
 is no longer used. However, a stale copy of it lying around could
 cause a build to fail. Removing it from .gitignore will make it more
 likely someone will notice that they have it lying around.
 ---

 Although this is a very simple change, I haven't used the trivial rule
 to push it, just to make sure everyone notices it, and nobody
 accidentally adds the file to git with git add ..
 If you have a long-lived tree, or plan on swapping to old commits prior
 to the point where we renamed things, I recommend doing:

 echo /daemon/probes.h  .git/info/exclude

 then you will be immune from 'git add .' accidentally re-adding it.

 Fresh checkouts are immune, and with this message serving as notice, I
 think we're okay.

 ACK.


And pushed.

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


Re: [libvirt] [PATCH] qemuBuildCommandLine: Don't add tlsPort if none set

2012-03-08 Thread Eric Blake
On 03/08/2012 06:30 AM, Michal Privoznik wrote:
 If user hasn't supplied any tlsPort we default to setting it
 to zero in our internal structure. However, when building command
 line we test it against -1 which is obviously wrong.
 ---
  src/qemu/qemu_command.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
 index de2d4a1..ed82cc2 100644
 --- a/src/qemu/qemu_command.c
 +++ b/src/qemu/qemu_command.c
 @@ -5374,7 +5374,7 @@ qemuBuildCommandLine(virConnectPtr conn,
  
  virBufferAsprintf(opt, port=%u, 
 def-graphics[0]-data.spice.port);
  
 -if (def-graphics[0]-data.spice.tlsPort != -1) {
 +if (def-graphics[0]-data.spice.tlsPort) {

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 0/9] Add supports for three new QMP events

2012-03-08 Thread Osier Yang

ping!

On 2012年03月05日 18:25, Osier Yang wrote:

This patch series adds support for 3 new QMP events: WAKEUP,
SUSPEND, and DEVICE_TRAY_MOVED, and related changes on domain's
conf and status.

[1/9]
   Add support for tray moved event

[2/9] ~ [5/9]:
   New attribute tray is added to disk target, it indicates
the tray status of removable disk, i.e. CDROM and Floppy disks,
its value could be either of open or closed, defaults to
closed, and a removable disk with tray == open won't have
the source when domain is started.  The value of tray will
be updated while tray moved event is emitted from guest.
   Prior to these patches, if the user ejected the medium of
removable disk from guest side, and then do migration or
save/restoring, the guest will still starts the medium source
,and thus the medium will still exists in guest, which is
strange. These patches fix it.

[6/9] + [8/9]:
   Add support for wakeup event, and update the domain status
to paused if the domain is running, while the wakeup event is
emitted.

[7/9] + [9/9]:
   Add support for suspend event, and update the domain status
to running if the domain was paused by suspend event, while the
suspend event is emitted.

Osier Yang(9)
   Add support for event tray moved of removable disks
   docs: Add documentation for new attribute tray of disk target
   conf: Parse and for the tray attribute
   qemu: Do not start with source for removable disks if tray is open
   qemu: Update tray status while tray moved event is emitted
   Add support for the wakeup event
   Add support for the event suspend
   qemu: Update domain status to paused while suspend event is emitted
   qemu: Update domain status to running while wakeup event is emitted

  daemon/remote.c|   80 +++
  docs/formatdomain.html.in  |   13 ++-
  docs/schemas/domaincommon.rng  |8 +
  examples/domain-events/events-c/event-test.c   |   61 -
  examples/domain-events/events-python/event-test.py |   12 ++
  include/libvirt/libvirt.h.in   |   56 
  python/libvirt-override-virConnect.py  |   27 
  python/libvirt-override.c  |  146 
  src/conf/domain_conf.c |   33 +-
  src/conf/domain_conf.h |9 ++
  src/conf/domain_event.c|  117 
  src/conf/domain_event.h|   10 ++
  src/libvirt_private.syms   |6 +
  src/qemu/qemu_command.c|   16 ++-
  src/qemu/qemu_monitor.c|   37 +
  src/qemu/qemu_monitor.h|   14 ++
  src/qemu/qemu_monitor_json.c   |   37 +-
  src/qemu/qemu_process.c|  131 ++
  src/remote/remote_driver.c |   98 +
  src/remote/remote_protocol.x   |   19 +++-
  src/remote_protocol-structs|   11 ++
  tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.xml |2 +-
  .../qemuxml2argv-boot-complex-bootindex.xml|6 +-
  .../qemuxml2argvdata/qemuxml2argv-boot-complex.xml |6 +-
  .../qemuxml2argvdata/qemuxml2argv-boot-floppy.xml  |2 +-
  ...uxml2argv-boot-menu-disable-drive-bootindex.xml |2 +-
  .../qemuxml2argv-boot-menu-disable-drive.xml   |2 +-
  .../qemuxml2argv-boot-menu-disable.xml |2 +-
  .../qemuxml2argv-boot-menu-enable.xml  |2 +-
  tests/qemuxml2argvdata/qemuxml2argv-boot-multi.xml |2 +-
  tests/qemuxml2argvdata/qemuxml2argv-boot-order.xml |4 +-
  tests/qemuxml2argvdata/qemuxml2argv-bootloader.xml |2 +-
  tests/qemuxml2argvdata/qemuxml2argv-disk-aio.xml   |2 +-
  .../qemuxml2argv-disk-cdrom-empty.xml  |2 +-
  ...qemuxml2argv-disk-cdrom-tray-no-device-cap.args |4 +
  .../qemuxml2argv-disk-cdrom-tray-no-device-cap.xml |   32 +
  .../qemuxml2argv-disk-cdrom-tray.args  |   10 ++
  .../qemuxml2argv-disk-cdrom-tray.xml   |   43 ++
  tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.xml |2 +-
  .../qemuxml2argv-disk-copy_on_read.xml |2 +-
  .../qemuxml2argv-disk-drive-boot-cdrom.xml |2 +-
  .../qemuxml2argv-disk-drive-boot-disk.xml  |2 +-
  .../qemuxml2argv-disk-drive-cache-directsync.xml   |2 +-
  .../qemuxml2argv-disk-drive-cache-unsafe.xml   |2 +-
  .../qemuxml2argv-disk-drive-cache-v1-none.xml  |2 +-
  .../qemuxml2argv-disk-drive-cache-v1-wb.xml|2 +-
  .../qemuxml2argv-disk-drive-cache-v1-wt.xml|2 +-
  .../qemuxml2argv-disk-drive-cache-v2-none.xml  |2 +-
  .../qemuxml2argv-disk-drive-cache-v2-wb.xml|2 +-
  .../qemuxml2argv-disk-drive-cache-v2-wt.xml|2 +-
  

Re: [libvirt] [PATCH v2] virsh: Use option alias for outmoded --persistent

2012-03-08 Thread Daniel Veillard
On Thu, Mar 08, 2012 at 07:38:57PM +0800, Osier Yang wrote:
 Since VIR_DOMAIN_AFFECT_{LIVE,CONFIG,CURRENT} was created,
 all new virsh commands use --config to represents the
 persistent changing. This patch add --config option
 for the old commands which still use --persistent,
 and --persistent is now alias of --config.
 
 tools/virsh.c: (use --config, and --persistent is
 alias of --config now).
 cmdDomIfSetLink, cmdDomIfGetLink, cmdAttachDevice,
 cmdDetachDevice, cmdUpdateDevice, cmdAttachInterface,
 cmdDetachInterface, cmdAttachDisk, cmdDetachDisk
 
 toos/virsh.pod: Update docs of the changed commands, and
 add some missed docs for --config (detach-interface,
 detach-disk, and detach-device).
 ---
  tools/virsh.c   |   51 ---
  tools/virsh.pod |   59 --
  2 files changed, 69 insertions(+), 41 deletions(-)
 
 diff --git a/tools/virsh.c b/tools/virsh.c
 index ee8ff31..9a16ef8 100644
 --- a/tools/virsh.c
 +++ b/tools/virsh.c
 @@ -1643,7 +1643,8 @@ static const vshCmdOptDef opts_domif_setlink[] = {
  {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
  {interface, VSH_OT_DATA, VSH_OFLAG_REQ, N_(interface device (MAC 
 Address))},
  {state, VSH_OT_DATA, VSH_OFLAG_REQ, N_(new state of the device)},
 -{persistent, VSH_OT_BOOL, 0, N_(persist interface state)},
 +{persistent, VSH_OT_ALIAS, 0, config},
 +{config, VSH_OT_BOOL, 0, N_(affect next boot)},
  {NULL, 0, 0, NULL}
  };
  
 @@ -1658,7 +1659,7 @@ cmdDomIfSetLink (vshControl *ctl, const vshCmd *cmd)
  unsigned char macaddr[VIR_MAC_BUFLEN];
  const char *element;
  const char *attr;
 -bool persistent;
 +bool config;
  bool ret = false;
  unsigned int flags = 0;
  int i;
 @@ -1680,7 +1681,7 @@ cmdDomIfSetLink (vshControl *ctl, const vshCmd *cmd)
  if (vshCommandOptString(cmd, state, state) = 0)
  goto cleanup;
  
 -persistent = vshCommandOptBool(cmd, persistent);
 +config = vshCommandOptBool(cmd, config);
  
  if (STRNEQ(state, up)  STRNEQ(state, down)) {
  vshError(ctl, _(invalid link state '%s'), state);
 @@ -1688,13 +1689,13 @@ cmdDomIfSetLink (vshControl *ctl, const vshCmd *cmd)
  }
  
  /* get persistent or live description of network device */
 -desc = virDomainGetXMLDesc(dom, persistent?VIR_DOMAIN_XML_INACTIVE:0);
 +desc = virDomainGetXMLDesc(dom, config ? VIR_DOMAIN_XML_INACTIVE : 0);
  if (desc == NULL) {
  vshError(ctl, _(Failed to get domain description xml));
  goto cleanup;
  }
  
 -if (persistent)
 +if (config)
  flags = VIR_DOMAIN_AFFECT_CONFIG;
  else
  flags = VIR_DOMAIN_AFFECT_LIVE;
 @@ -1818,7 +1819,8 @@ static const vshCmdInfo info_domif_getlink[] = {
  static const vshCmdOptDef opts_domif_getlink[] = {
  {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
  {interface, VSH_OT_DATA, VSH_OFLAG_REQ, N_(interface device (MAC 
 Address))},
 -{persistent, VSH_OT_BOOL, 0, N_(Get persistent interface state)},
 +{persistent, VSH_OT_ALIAS, 0, config},
 +{config, VSH_OT_BOOL, 0, N_(Get persistent interface state)},
  {NULL, 0, 0, NULL}
  };
  
 @@ -1852,7 +1854,7 @@ cmdDomIfGetLink (vshControl *ctl, const vshCmd *cmd)
  return false;
  }
  
 -if (vshCommandOptBool(cmd, persistent))
 +if (vshCommandOptBool(cmd, config))
  flags = VIR_DOMAIN_XML_INACTIVE;
  
  desc = virDomainGetXMLDesc(dom, flags);
 @@ -13460,7 +13462,8 @@ static const vshCmdInfo info_attach_device[] = {
  static const vshCmdOptDef opts_attach_device[] = {
  {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
  {file,   VSH_OT_DATA, VSH_OFLAG_REQ, N_(XML file)},
 -{persistent, VSH_OT_BOOL, 0, N_(persist device attachment)},
 +{persistent, VSH_OT_ALIAS, 0, config},
 +{config, VSH_OT_BOOL, 0, N_(affect next boot)},
  {NULL, 0, 0, NULL}
  };

 @@ -13490,7 +13493,7 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
  return false;
  }
  
 -if (vshCommandOptBool(cmd, persistent)) {
 +if (vshCommandOptBool(cmd, config)) {
  flags = VIR_DOMAIN_AFFECT_CONFIG;
  if (virDomainIsActive(dom) == 1)
 flags |= VIR_DOMAIN_AFFECT_LIVE;
 @@ -13771,7 +13774,8 @@ static const vshCmdInfo info_detach_device[] = {
  static const vshCmdOptDef opts_detach_device[] = {
  {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
  {file,   VSH_OT_DATA, VSH_OFLAG_REQ, N_(XML file)},
 -{persistent, VSH_OT_BOOL, 0, N_(persist device detachment)},
 +{persistent, VSH_OT_ALIAS, 0, config},
 +{config, VSH_OT_BOOL, 0, N_(affect next boot)},
  {NULL, 0, 0, NULL}
  };

 @@ -13799,7 +13803,7 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
  goto cleanup;
  }
  
 -if (vshCommandOptBool(cmd, persistent)) {
 +if 

Re: [libvirt] [PATCH v2] virsh: Use option alias for outmoded --persistent

2012-03-08 Thread Osier Yang

On 2012年03月09日 10:55, Daniel Veillard wrote:

On Thu, Mar 08, 2012 at 07:38:57PM +0800, Osier Yang wrote:

Since VIR_DOMAIN_AFFECT_{LIVE,CONFIG,CURRENT} was created,
all new virsh commands use --config to represents the
persistent changing. This patch add --config option
for the old commands which still use --persistent,
and --persistent is now alias of --config.

tools/virsh.c: (use --config, and --persistent is
 alias of --config now).
 cmdDomIfSetLink, cmdDomIfGetLink, cmdAttachDevice,
 cmdDetachDevice, cmdUpdateDevice, cmdAttachInterface,
 cmdDetachInterface, cmdAttachDisk, cmdDetachDisk

toos/virsh.pod: Update docs of the changed commands, and
 add some missed docs for --config (detach-interface,
 detach-disk, and detach-device).
---
  tools/virsh.c   |   51 ---
  tools/virsh.pod |   59 --
  2 files changed, 69 insertions(+), 41 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index ee8ff31..9a16ef8 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1643,7 +1643,8 @@ static const vshCmdOptDef opts_domif_setlink[] = {
  {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
  {interface, VSH_OT_DATA, VSH_OFLAG_REQ, N_(interface device (MAC 
Address))},
  {state, VSH_OT_DATA, VSH_OFLAG_REQ, N_(new state of the device)},
-{persistent, VSH_OT_BOOL, 0, N_(persist interface state)},
+{persistent, VSH_OT_ALIAS, 0, config},
+{config, VSH_OT_BOOL, 0, N_(affect next boot)},
  {NULL, 0, 0, NULL}
  };

@@ -1658,7 +1659,7 @@ cmdDomIfSetLink (vshControl *ctl, const vshCmd *cmd)
  unsigned char macaddr[VIR_MAC_BUFLEN];
  const char *element;
  const char *attr;
-bool persistent;
+bool config;
  bool ret = false;
  unsigned int flags = 0;
  int i;
@@ -1680,7 +1681,7 @@ cmdDomIfSetLink (vshControl *ctl, const vshCmd *cmd)
  if (vshCommandOptString(cmd, state,state)= 0)
  goto cleanup;

-persistent = vshCommandOptBool(cmd, persistent);
+config = vshCommandOptBool(cmd, config);

  if (STRNEQ(state, up)  STRNEQ(state, down)) {
  vshError(ctl, _(invalid link state '%s'), state);
@@ -1688,13 +1689,13 @@ cmdDomIfSetLink (vshControl *ctl, const vshCmd *cmd)
  }

  /* get persistent or live description of network device */
-desc = virDomainGetXMLDesc(dom, persistent?VIR_DOMAIN_XML_INACTIVE:0);
+desc = virDomainGetXMLDesc(dom, config ? VIR_DOMAIN_XML_INACTIVE : 0);
  if (desc == NULL) {
  vshError(ctl, _(Failed to get domain description xml));
  goto cleanup;
  }

-if (persistent)
+if (config)
  flags = VIR_DOMAIN_AFFECT_CONFIG;
  else
  flags = VIR_DOMAIN_AFFECT_LIVE;
@@ -1818,7 +1819,8 @@ static const vshCmdInfo info_domif_getlink[] = {
  static const vshCmdOptDef opts_domif_getlink[] = {
  {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
  {interface, VSH_OT_DATA, VSH_OFLAG_REQ, N_(interface device (MAC 
Address))},
-{persistent, VSH_OT_BOOL, 0, N_(Get persistent interface state)},
+{persistent, VSH_OT_ALIAS, 0, config},
+{config, VSH_OT_BOOL, 0, N_(Get persistent interface state)},
  {NULL, 0, 0, NULL}
  };

@@ -1852,7 +1854,7 @@ cmdDomIfGetLink (vshControl *ctl, const vshCmd *cmd)
  return false;
  }

-if (vshCommandOptBool(cmd, persistent))
+if (vshCommandOptBool(cmd, config))
  flags = VIR_DOMAIN_XML_INACTIVE;

  desc = virDomainGetXMLDesc(dom, flags);
@@ -13460,7 +13462,8 @@ static const vshCmdInfo info_attach_device[] = {
  static const vshCmdOptDef opts_attach_device[] = {
  {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
  {file,   VSH_OT_DATA, VSH_OFLAG_REQ, N_(XML file)},
-{persistent, VSH_OT_BOOL, 0, N_(persist device attachment)},
+{persistent, VSH_OT_ALIAS, 0, config},
+{config, VSH_OT_BOOL, 0, N_(affect next boot)},
  {NULL, 0, 0, NULL}
  };

@@ -13490,7 +13493,7 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
  return false;
  }

-if (vshCommandOptBool(cmd, persistent)) {
+if (vshCommandOptBool(cmd, config)) {
  flags = VIR_DOMAIN_AFFECT_CONFIG;
  if (virDomainIsActive(dom) == 1)
 flags |= VIR_DOMAIN_AFFECT_LIVE;
@@ -13771,7 +13774,8 @@ static const vshCmdInfo info_detach_device[] = {
  static const vshCmdOptDef opts_detach_device[] = {
  {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
  {file,   VSH_OT_DATA, VSH_OFLAG_REQ, N_(XML file)},
-{persistent, VSH_OT_BOOL, 0, N_(persist device detachment)},
+{persistent, VSH_OT_ALIAS, 0, config},
+{config, VSH_OT_BOOL, 0, N_(affect next boot)},
  {NULL, 0, 0, NULL}
  };

@@ -13799,7 +13803,7 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
  goto cleanup;
  }

-if (vshCommandOptBool(cmd, persistent)) {
+if (vshCommandOptBool(cmd, 

Re: [libvirt] libvirt_tck autotest wrapper looks good, commited

2012-03-08 Thread Guannan Ren

On 03/09/2012 01:40 AM, Lucas Meneghel Rodrigues wrote:

Thanks Guannan:

https://github.com/autotest/autotest/commit/ba4b748e7b9a9bfe7898a97cdccdc9b867d5321c 



Cheers,

Lucas


   That's great, thank Lucas.
   This is the initial version, we need to maintain it later on.
   If that, the patch will be sent to autotest mainling list, is that 
right?


   Guannan Ren


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


Re: [libvirt] [Patch]: spice agent-mouse support [v3]

2012-03-08 Thread Osier Yang

On 2012年03月07日 19:57, Zhou Peng wrote:

Sorry my git send-email failed to the list :-(

Signed-off-by: Zhou Pengzhoup...@nfs.iscas.ac.cn

spice agent-mouse support

Usage:
graphics type='spice'
   mouse mode='client'|'server'/
graphics/



Pushed with the attached diff squashed in. You are added
in the contributors list now, please let me known if you'd
like another name. Thanks for the patch!

Regards,
Osier

diff --git a/AUTHORS b/AUTHORS
index 954fd1a..e4bd51d 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -224,6 +224,7 @@ Patches have also been contributed by:
   Peter Robinson   pbrobin...@gmail.com
   Benjamin Camaben...@dolka.fr
   Duncan Rance libv...@dunquino.com
+  Peng Zhouailvpen...@gmail.com
 
   [send patches to get your name here]
 
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index d8ced3a..bf0675e 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2851,6 +2851,7 @@ qemu-kvm -net nic,model=? /dev/null
 lt;image compression='auto_glz'/gt;
 lt;streaming mode='filter'/gt;
 lt;clipboard copypaste='no'/gt;
+lt;mouse mode='client'/gt;
   lt;/graphicsgt;/pre
 p
   Spice supports variable compression settings for audio,
@@ -2888,7 +2889,7 @@ qemu-kvm -net nic,model=? /dev/null
   setting it's codemodecode/ attribute to one of
   codeserver/code or codeclient/code ,
   span class=sincesince 0.9.11/span. If no mode is
-  specified, the spice default will be used (client mode).
+  specified, the qemu default will be used (client mode).
 /p
   /dd
   dtcoderdp/code/dt
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 2238558..d7ec221 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -253,8 +253,6 @@ virDomainChrDefFree;
 virDomainChrDefNew;
 virDomainChrSourceDefCopy;
 virDomainChrSourceDefFree;
-virDomainGraphicsSpiceMouseModeTypeFromString;
-virDomainGraphicsSpiceMouseModeTypeToString;
 virDomainChrSpicevmcTypeFromString;
 virDomainChrSpicevmcTypeToString;
 virDomainChrTcpProtocolTypeFromString;
@@ -347,6 +345,8 @@ virDomainGraphicsSpiceImageCompressionTypeFromString;
 virDomainGraphicsSpiceImageCompressionTypeToString;
 virDomainGraphicsSpiceJpegCompressionTypeFromString;
 virDomainGraphicsSpiceJpegCompressionTypeToString;
+virDomainGraphicsSpiceMouseModeTypeFromString;
+virDomainGraphicsSpiceMouseModeTypeToString;
 virDomainGraphicsSpicePlaybackCompressionTypeFromString;
 virDomainGraphicsSpicePlaybackCompressionTypeToString;
 virDomainGraphicsSpiceStreamingModeTypeFromString;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agentmouse.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agentmouse.args
new file mode 100644
index 000..2c3ef06
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agentmouse.args
@@ -0,0 +1,8 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice \
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nodefconfig -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
+-device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa \
+-hda /dev/HostVG/QEMUGuest1 -chardev spicevmc,id=charchannel0,name=vdagent \
+-device virtserialport,bus=virtio-serial1.0,nr=3,chardev=charchannel0,id=channel0,name=com.redhat.spice.0 \
+-usb -spice port=5903,tls-port=5904,addr=127.0.0.1,agent-mouse=off,x509-dir=/etc/pki/libvirt-spice,tls-channel=main \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-spice-agentmouse.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agentmouse.xml
similarity index 100%
rename from tests/qemuxml2argvdata/qemuxml2argv-spice-agentmouse.xml
rename to tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agentmouse.xml
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-spice-agentmouse.args b/tests/qemuxml2argvdata/qemuxml2argv-spice-agentmouse.args
deleted file mode 100644
index 746c116..000
--- a/tests/qemuxml2argvdata/qemuxml2argv-spice-agentmouse.args
+++ /dev/null
@@ -1,9 +0,0 @@
-LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice \
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nodefconfig -nodefaults \
--monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device \
-virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa -hda \
-/dev/HostVG/QEMUGuest1 -chardev spicevmc,id=charchannel0,name=vdagent -device \
-virtserialport,bus=virtio-serial1.0,nr=3,chardev=charchannel0,id=channel0\
-,name=com.redhat.spice.0 -usb -spice port=5903,tls-port=5904,addr=127.0.0.1,\
-agent-mouse=off,x509-dir=/etc/pki/libvirt-spice,tls-channel=main -device \
-virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 0abc9cf..3cfd69c 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c