Re: [libvirt] [PATCH v4] parallels: add block device statistics to driver

2015-06-08 Thread Dmitry Guryanov

On 06/05/2015 05:17 PM, Nikolay Shirokovskiy wrote:

  static int
  parallelsDoCmdRun(char **outbuf, const char *binary, va_list list)
diff --git a/src/parallels/parallels_utils.h b/src/parallels/parallels_utils.h
index 2d1d405..cdf6082 100644
--- a/src/parallels/parallels_utils.h
+++ b/src/parallels/parallels_utils.h
@@ -73,11 +73,22 @@ struct _parallelsConn {
  typedef struct _parallelsConn parallelsConn;
  typedef struct _parallelsConn *parallelsConnPtr;
  
+struct _parallelsContersCache {


Is it a typo? Why not counters?



+PRL_HANDLE stats;
+virCond cond;
+// -1 - unsubscribed
+//  -1 - subscribed
+int count;
+};
+
+typedef struct _parallelsContersCache parallelsContersCache;
+
  struct parallelsDomObj {
  int id;
  char *uuid;
  char *home;
  PRL_HANDLE sdkdom;
+parallelsContersCache cache;
  };
  
  typedef struct parallelsDomObj *parallelsDomObjPtr;

@@ -91,6 +102,7 @@ int parallelsNetworkClose(virConnectPtr conn);
  extern virNetworkDriver parallelsNetworkDriver;
  
  virDomainObjPtr parallelsDomObjFromDomain(virDomainPtr domain);

+virDomainObjPtr parallelsDomObjFromDomainRef(virDomainPtr domain);
  
  virJSONValuePtr parallelsParseOutput(const char *binary, ...)

  ATTRIBUTE_NONNULL(1) ATTRIBUTE_SENTINEL;
@@ -106,4 +118,10 @@ virStorageVolPtr 
parallelsStorageVolLookupByPathLocked(virConnectPtr conn,
  int parallelsStorageVolDefRemove(virStoragePoolObjPtr privpool,
   virStorageVolDefPtr privvol);
  
+#define PARALLELS_BLOCK_STATS_FOREACH(OP)   \

+OP(rd_req, VIR_DOMAIN_BLOCK_STATS_READ_REQ, read_requests)\
+OP(rd_bytes, VIR_DOMAIN_BLOCK_STATS_READ_BYTES, read_total)   \
+OP(wr_req, VIR_DOMAIN_BLOCK_STATS_WRITE_REQ, write_requests)  \
+OP(wr_bytes, VIR_DOMAIN_BLOCK_STATS_WRITE_BYTES, write_total)
+
  #endif


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


Re: [libvirt] [PATCH] parallels: return only success from PCS event handler

2015-06-08 Thread Dmitry Guryanov

On 06/05/2015 04:47 PM, Nikolay Shirokovskiy wrote:

2 reasons to to this.
1. PCS SDK really don't care of handler return value.
2. It hard to imagine how notifier can handle
subscriber failures. Even if there are some situations
we probably will use some special error codes and
not just throw error codes we get from SDK itself.


Pushed, thanks!



Signed-off-by: Nikolay Shirokovskiy nshirokovs...@parallels.com
---
  src/parallels/parallels_sdk.c |  121 -
  1 files changed, 47 insertions(+), 74 deletions(-)

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index d5a9790..6d63759 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -1516,7 +1516,7 @@ prlsdkNewStateToEvent(VIRTUAL_MACHINE_STATE domainState,
  }
  }
  
-static PRL_RESULT

+static void
  prlsdkHandleVmStateEvent(parallelsConnPtr privconn,
   PRL_HANDLE prlEvent,
   unsigned char *uuid)
@@ -1529,18 +1529,16 @@ prlsdkHandleVmStateEvent(parallelsConnPtr privconn,
  virDomainEventType lvEventType = 0;
  int lvEventTypeDetails = 0;
  
+dom = virDomainObjListFindByUUID(privconn-domains, uuid);

+if (dom == NULL)
+return;
+
  pret = PrlEvent_GetParamByName(prlEvent, vminfo_vm_state, eventParam);
  prlsdkCheckRetGoto(pret, cleanup);
  
  pret = PrlEvtPrm_ToInt32(eventParam, domainState);

  prlsdkCheckRetGoto(pret, cleanup);
  
-dom = virDomainObjListFindByUUID(privconn-domains, uuid);

-if (dom == NULL) {
-pret = PRL_ERR_VM_UUID_NOT_FOUND;
-goto cleanup;
-}
-
  pdom = dom-privateData;
  if (prlsdkConvertDomainState(domainState, pdom-id, dom)  0)
  goto cleanup;
@@ -1549,96 +1547,74 @@ prlsdkHandleVmStateEvent(parallelsConnPtr privconn,
lvEventType,
lvEventTypeDetails);
  
-if (prlsdkSendEvent(privconn, dom, lvEventType, lvEventTypeDetails)  0) {

-pret = PRL_ERR_OUT_OF_MEMORY;
-goto cleanup;
-}
+prlsdkSendEvent(privconn, dom, lvEventType, lvEventTypeDetails);
  
   cleanup:

-if (dom)
-virObjectUnlock(dom);
-return pret;
+virObjectUnlock(dom);
+return;
  }
  
-static PRL_RESULT

+static void
  prlsdkHandleVmConfigEvent(parallelsConnPtr privconn,
unsigned char *uuid)
  {
-PRL_RESULT pret = PRL_ERR_FAILURE;
  virDomainObjPtr dom = NULL;
  
  dom = virDomainObjListFindByUUID(privconn-domains, uuid);

-if (dom == NULL) {
-pret = PRL_ERR_VM_UUID_NOT_FOUND;
-goto cleanup;
-}
+if (dom == NULL)
+return;
  
  if (prlsdkUpdateDomain(privconn, dom)  0)

  goto cleanup;
  
-if (prlsdkSendEvent(privconn, dom, VIR_DOMAIN_EVENT_DEFINED,

-VIR_DOMAIN_EVENT_DEFINED_UPDATED)  0) {
-pret = PRL_ERR_OUT_OF_MEMORY;
-goto cleanup;
-}
+prlsdkSendEvent(privconn, dom, VIR_DOMAIN_EVENT_DEFINED,
+VIR_DOMAIN_EVENT_DEFINED_UPDATED);
  
-pret = PRL_ERR_SUCCESS;

   cleanup:
-if (dom)
-virObjectUnlock(dom);
-return pret;
+virObjectUnlock(dom);
+return;
  }
  
-static PRL_RESULT

+static void
  prlsdkHandleVmAddedEvent(parallelsConnPtr privconn,
 unsigned char *uuid)
  {
-PRL_RESULT pret;
  virDomainObjPtr dom = NULL;
  
  dom = prlsdkAddDomain(privconn, uuid);

-if (!dom)
-return PRL_ERR_FAILURE;
+if (dom == NULL)
+return;
  
-if (prlsdkSendEvent(privconn, dom, VIR_DOMAIN_EVENT_DEFINED,

-VIR_DOMAIN_EVENT_DEFINED_ADDED)  0) {
-pret = PRL_ERR_OUT_OF_MEMORY;
-goto cleanup;
-}
+prlsdkSendEvent(privconn, dom, VIR_DOMAIN_EVENT_DEFINED,
+VIR_DOMAIN_EVENT_DEFINED_ADDED);
  
-pret = PRL_ERR_SUCCESS;

- cleanup:
-if (dom)
-virObjectUnlock(dom);
-return pret;
+virObjectUnlock(dom);
+return;
  }
  
-static PRL_RESULT

+static void
  prlsdkHandleVmRemovedEvent(parallelsConnPtr privconn,
 unsigned char *uuid)
  {
  virDomainObjPtr dom = NULL;
-PRL_RESULT pret = PRL_ERR_SUCCESS;
  
  dom = virDomainObjListFindByUUID(privconn-domains, uuid);

-if (dom == NULL) {
-/* domain was removed from the list from the libvirt
- * API function in current connection */
-return PRL_ERR_SUCCESS;
-}
+/* domain was removed from the list from the libvirt
+ * API function in current connection */
+if (dom == NULL)
+return;
  
-if (prlsdkSendEvent(privconn, dom, VIR_DOMAIN_EVENT_UNDEFINED,

-VIR_DOMAIN_EVENT_UNDEFINED_REMOVED)  0)
-pret = PRL_ERR_OUT_OF_MEMORY;
+prlsdkSendEvent(privconn, dom, VIR_DOMAIN_EVENT_UNDEFINED,
+VIR_DOMAIN_EVENT_UNDEFINED_REMOVED);
  
  

[libvirt] [PATCH] storage: Need to set secrettype for direct iscsi disk volume

2015-06-08 Thread John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1200206

Commit id '1b4eaa61' added the ability to have a mode='direct' for
an iscsi disk volume.  It relied on virStorageTranslateDiskSourcePool
in order to copy any disk source pool authentication information to
the direct disk volume, but it neglected to also copy the 'secrettype'
field which ends up being used in the domain volume formatting code.
Adding a secrettype for this case will allow for proper formatting later
and allow disk snapshotting to work properly

Signed-off-by: John Ferlan jfer...@redhat.com
---
 src/storage/storage_driver.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index ab8675d..57060ab 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -3310,6 +3310,16 @@ virStorageTranslateDiskSourcePool(virConnectPtr conn,
  pooldef-source)  0)
goto cleanup;
 
+   /* Source pool may not fill in the secrettype field,
+* so we need to do so here
+*/
+   if (def-src-auth  !def-src-auth-secrettype) {
+   const char *secrettype =
+   virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_ISCSI);
+   if (VIR_STRDUP(def-src-auth-secrettype, secrettype)  0)
+   goto cleanup;
+   }
+
if (virStorageAddISCSIPoolSourceHost(def, pooldef)  0)
goto cleanup;
break;
-- 
2.1.0

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


Re: [libvirt] [PATCH 3/3] qemu: caps: Advertise arm 32-on-64 KVM option

2015-06-08 Thread Cole Robinson
On 06/08/2015 04:46 AM, Daniel P. Berrange wrote:
 On Sat, Jun 06, 2015 at 07:06:42PM -0400, Cole Robinson wrote:
 On 05/28/2015 07:31 AM, Daniel P. Berrange wrote:
 On Thu, May 21, 2015 at 07:03:28PM -0400, Cole Robinson wrote:
 We need to use qemu-system-aarch64 to run armv7l KVM VMs on an aarch64
 host.
 ---
  src/qemu/qemu_capabilities.c | 42 
 ++
  1 file changed, 22 insertions(+), 20 deletions(-)

 diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
 index 1e7bddb..7181865 100644
 --- a/src/qemu/qemu_capabilities.c
 +++ b/src/qemu/qemu_capabilities.c
 @@ -723,19 +723,6 @@ virQEMUCapsFindBinaryForArch(virArch hostarch,
  return ret;
  }
  
 -
 -static bool
 -virQEMUCapsIsValidForKVM(virArch hostarch,
 - virArch guestarch)
 -{
 -if (hostarch == guestarch)
 -return true;
 -if (hostarch == VIR_ARCH_X86_64 
 -guestarch == VIR_ARCH_I686)
 -return true;
 -return false;
 -}
 -
  static int
  virQEMUCapsInitGuest(virCapsPtr caps,
   virQEMUCapsCachePtr cache,
 @@ -747,6 +734,7 @@ virQEMUCapsInitGuest(virCapsPtr caps,
  char *binary = NULL;
  virQEMUCapsPtr qemubinCaps = NULL;
  virQEMUCapsPtr kvmbinCaps = NULL;
 +bool native_kvm, x86_32on64_kvm, arm_32on64_kvm;
  int ret = -1;
  
  /* Check for existence of base emulator, or alternate base
 @@ -764,16 +752,30 @@ virQEMUCapsInitGuest(virCapsPtr caps,
  
  /* qemu-kvm/kvm binaries can only be used if
   *  - host  guest arches match
 - * Or
 - *  - hostarch is x86_64 and guest arch is i686
 - * The latter simply needs -cpu qemu32
 + *  - hostarch is x86_64 and guest arch is i686 (needs -cpu qemu32)
 + *  - hostarch is aarch64 and guest arch is armv7l (needs -cpu 
 aarch64=off)
   */
 -if (virQEMUCapsIsValidForKVM(hostarch, guestarch)) {
 -const char *const kvmbins[] = { /usr/libexec/qemu-kvm, /* RHEL 
 */
 -qemu-kvm, /* Fedora */
 -kvm }; /* Upstream .spec */
 +native_kvm = (hostarch == guestarch);
 +x86_32on64_kvm = (hostarch == VIR_ARCH_X86_64 
 +guestarch == VIR_ARCH_I686);
 +arm_32on64_kvm = (hostarch == VIR_ARCH_AARCH64 
 +guestarch == VIR_ARCH_ARMV7L);
 +
 +if (native_kvm || x86_32on64_kvm || arm_32on64_kvm) {
 +const char *kvmbins[] = {
 +/usr/libexec/qemu-kvm, /* RHEL */
 +qemu-kvm, /* Fedora */
 +kvm, /* Debian/Ubuntu */
 +NULL,
 +};
 +
 +if (arm_32on64_kvm)
 +kvmbins[3] = qemu-system-aarch64;

 I'm unclear why you need to be adding this. We don't need it for
 the equivalent i686 with qemu-system-x86_64, as the earlier call
 to virQEMUCapsFindBinaryForArch() will already return the binary
 qemu-system-x86_64. IIUC, it should have returned the binary
 qemu-system-aarch64 too, so this just seems to duplicate the
 check for that binary.

 We need this in the case you are running on an aarch64 host and have both
 qemu-system-arm and qemu-system-aarch64 installed. In this case, when you 
 want
 to use KVM for arm32, you _have_ to use qemu-system-aarch64, qemu-system-arm
 does not work. What you suggest would mean that qemu-system-arm is grabbed
 from the caps cache.

 x86 doesn't have this problem because qemu-system-i386, qemu-system-x86_64 
 and
 by extension qemu-kvm can all be used to do 32-on-64 KVM.
 
 Ok, I think we need to have this explained in the code comments, because
 that is none obvious from reading the code  we don't want to be wondering
 why we did this when looking at the code again in a year :-)
 

Good point, I squashed in this and pushed:

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 50361fd..ca7a7c2 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -769,6 +769,14 @@ virQEMUCapsInitGuest(virCapsPtr caps,
 NULL,
 };

+/* x86 32-on-64 can be used with qemu-system-i386 and
+ * qemu-system-x86_64, so if we don't find a specific kvm binary,
+ * we can just fall back to the host arch native binary and
+ * everything works fine.
+ *
+ * arm is different in that 32-on-64 _only_ works with
+ * qemu-system-aarch64. So we have to add it to the kvmbins list
+ */
 if (arm_32on64_kvm)
 kvmbins[3] = qemu-system-aarch64;

Thanks,
Cole



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


Re: [libvirt] [PATCH v2] parallels: simplify event types discrimination

2015-06-08 Thread Dmitry Guryanov

On 06/04/2015 02:45 PM, Nikolay Shirokovskiy wrote:

Use issuer type instead of event type to group
vm related events. This saves us from
explicit enumeration of all vm event types in
prlsdkHandleVmEvent.


Thanks, ACKed and pushed.


---
  src/parallels/parallels_sdk.c |   15 +--
  1 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index 88ad59b..d5a9790 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -1681,7 +1681,7 @@ prlsdkEventsHandler(PRL_HANDLE prlEvent, PRL_VOID_PTR 
opaque)
  parallelsConnPtr privconn = opaque;
  PRL_RESULT pret = PRL_ERR_UNINITIALIZED;
  PRL_HANDLE_TYPE handleType;
-PRL_EVENT_TYPE prlEventType;
+PRL_EVENT_ISSUER_TYPE prlIssuerType = PIE_UNKNOWN;
  
  pret = PrlHandle_GetType(prlEvent, handleType);

  prlsdkCheckRetGoto(pret, cleanup);
@@ -1697,20 +1697,15 @@ prlsdkEventsHandler(PRL_HANDLE prlEvent, PRL_VOID_PTR 
opaque)
  goto cleanup;
  }
  
-PrlEvent_GetType(prlEvent, prlEventType);

+PrlEvent_GetIssuerType(prlEvent, prlIssuerType);
  prlsdkCheckRetGoto(pret, cleanup);
  
-switch (prlEventType) {

-case PET_DSP_EVT_VM_STATE_CHANGED:
-case PET_DSP_EVT_VM_CONFIG_CHANGED:
-case PET_DSP_EVT_VM_CREATED:
-case PET_DSP_EVT_VM_ADDED:
-case PET_DSP_EVT_VM_DELETED:
-case PET_DSP_EVT_VM_UNREGISTERED:
+switch (prlIssuerType) {
+case PIE_VIRTUAL_MACHINE:
  pret = prlsdkHandleVmEvent(privconn, prlEvent);
  break;
  default:
-VIR_DEBUG(Skipping event of type %d, prlEventType);
+VIR_DEBUG(Skipping event of issuer type %d, prlIssuerType);
  }
  
  pret = PRL_ERR_SUCCESS;


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


[libvirt] [PATCH] libxl: Add timestamp to the libxl driver log.

2015-06-08 Thread Anthony PERARD
Signed-off-by: Anthony PERARD anthony.per...@citrix.com
---
 src/libxl/libxl_conf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 9b258ac..e845759 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1541,7 +1541,7 @@ libxlDriverConfigNew(void)
 
 cfg-logger =
 (xentoollog_logger *)xtl_createlogger_stdiostream(cfg-logger_file,
-  XTL_DEBUG, 0);
+  XTL_DEBUG, XTL_STDIOSTREAM_SHOW_DATE);
 if (!cfg-logger) {
 VIR_ERROR(_(cannot create logger for libxenlight, disabling driver));
 goto error;
-- 
Anthony PERARD

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


Re: [libvirt] [PATCH] storage: add RBD support to disk source pool translation

2015-06-08 Thread Thibault VINCENT
Hello,
Any idea about this one?
Not sure if it's bad or getting lost in backlog, and I'd like to see it in next 
release.
Cheers

-- 
Thibault

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


[libvirt] [PATCH] util: Properly return error from virGetUserID and virGetGroupID stubs

2015-06-08 Thread Peter Krempa
The stubs for the two functions that are compiled on platforms that
don't have HAVE_GETPWUID_R and friends defined do not return error but
report an error message. The calling code then assumes that the @uid or
@gid arguments were filled, which is not the case in the stubs.
---

This should fix the mingw build that complains that @theuid in one of the
callers is not initialized.

 src/util/virutil.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/virutil.c b/src/util/virutil.c
index e479cce..cddc78a 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -1316,7 +1316,7 @@ int virGetUserID(const char *name ATTRIBUTE_UNUSED,
 virReportError(VIR_ERR_INTERNAL_ERROR,
%s, _(virGetUserID is not available));

-return 0;
+return -1;
 }


@@ -1326,7 +1326,7 @@ int virGetGroupID(const char *name ATTRIBUTE_UNUSED,
 virReportError(VIR_ERR_INTERNAL_ERROR,
%s, _(virGetGroupID is not available));

-return 0;
+return -1;
 }

 int
-- 
2.4.1

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


Re: [libvirt] [PATCH] util: Properly return error from virGetUserID and virGetGroupID stubs

2015-06-08 Thread Ján Tomko
On Mon, Jun 08, 2015 at 09:35:44AM +0200, Peter Krempa wrote:
 The stubs for the two functions that are compiled on platforms that
 don't have HAVE_GETPWUID_R and friends defined do not return error but
 report an error message. The calling code then assumes that the @uid or
 @gid arguments were filled, which is not the case in the stubs.
 ---
 
 This should fix the mingw build that complains that @theuid in one of the
 callers is not initialized.
 
  src/util/virutil.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

ACK

Jan


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

[libvirt] [PATCH] qemu: update netdevs of the same mac addrs correctly

2015-06-08 Thread zhang bo
If a guest has multiple network devices with the same MAC address,
when we online update the second device, libvirtd always updates
the first one.

commit def31e4c forgot to fix the online updating scenario. We need to
use virDomainNetFindIdx() to find the correct network device.

Signed-off-by: Zhou Yimin zhouyi...@huawei.com
Signed-off-by: Zhang Bo oscar.zhan...@huawei.com
---
 src/qemu/qemu_hotplug.c | 23 +++
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 94ebe35..d455bd6 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2052,20 +2052,6 @@ int qemuDomainAttachHostDevice(virConnectPtr conn,
 return -1;
 }
 
-static virDomainNetDefPtr *qemuDomainFindNet(virDomainObjPtr vm,
- virDomainNetDefPtr dev)
-{
-size_t i;
-
-for (i = 0; i  vm-def-nnets; i++) {
-if (virMacAddrCmp(vm-def-nets[i]-mac, dev-mac) == 0)
-return vm-def-nets[i];
-}
-
-return NULL;
-}
-
-
 static int
 qemuDomainChangeNetBridge(virDomainObjPtr vm,
   virDomainNetDefPtr olddev,
@@ -2195,7 +2181,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
 virDomainDeviceDefPtr dev)
 {
 virDomainNetDefPtr newdev = dev-data.net;
-virDomainNetDefPtr *devslot = qemuDomainFindNet(vm, newdev);
+virDomainNetDefPtr *devslot = NULL;
 virDomainNetDefPtr olddev;
 int oldType, newType;
 bool needReconnect = false;
@@ -2205,8 +2191,13 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
 bool needReplaceDevDef = false;
 bool needBandwidthSet = false;
 int ret = -1;
+int changeidx = -1;
+
+if ((changeidx = virDomainNetFindIdx(vm-def, newdev))  0)
+goto cleanup;
+devslot = vm-def-nets[changeidx];
 
-if (!devslot || !(olddev = *devslot)) {
+if (!(olddev = *devslot)) {
 virReportError(VIR_ERR_OPERATION_FAILED, %s,
_(cannot find existing network device to modify));
 goto cleanup;
-- 
1.7.12.4


-- 
Oscar
oscar.zhan...@huawei.com  

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


[libvirt] [PATCH 2/2] utiltest: Don't assume 'char' is always signed

2015-06-08 Thread Michal Privoznik
Not every architecture out there has 'char' signed by default.
For instance, my arm box has it unsigned by default:

  $ gcc -dM -E -  /dev/null | grep __CHAR_UNSIGNED__
  #define __CHAR_UNSIGNED__ 1

Therefore, after 65c61e50 the test if failing for me. Problem is,
we are trying to assign couple of negative values into char
assuming some will overflow and some don't. That can't be the
case if 'char' is unsigned by default.

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
 tests/utiltest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/utiltest.c b/tests/utiltest.c
index 3a1f8eb..9eb7fb6 100644
--- a/tests/utiltest.c
+++ b/tests/utiltest.c
@@ -185,7 +185,7 @@ testOverflowCheckMacro(const void *data ATTRIBUTE_UNUSED)
 {
 long long tmp;
 unsigned char luchar;
-char lchar;
+signed char lchar;
 
 TEST_OVERFLOW(luchar, 254, false);
 TEST_OVERFLOW(luchar, 255, false);
-- 
2.3.6

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


Re: [libvirt] [PATCH 1/2] utils: Return proper value for virGet{User, Group}ID

2015-06-08 Thread Martin Kletzander

On Mon, Jun 08, 2015 at 10:43:38AM +0200, Michal Privoznik wrote:

These two functions are used to translate user or group name into
a numerical ID. Depending on platform we are building for, we
have an implementation for UNIX-like systems, and a stub
implementation for Windows. While the former returns a negative
value on error, the latter simply reports an error (saying
something about missing implementation) and returns the value of
zero. This makes the caller think function did succeed and passed
variable had been set to the correct value. Well, it was not.
Even compiler spots this when compiling for win32:

 CC   util/libvirt_util_la-virutil.lo
../../src/util/virutil.c: In function 'virParseOwnershipIds':
../../src/util/virutil.c:2410:17: error: 'theuid' may be used uninitialized in 
this function [-Werror=maybe-uninitialized]
*uidPtr = theuid;
^
../../src/util/virutil.c:2380:9: note: 'theuid' was declared here
uid_t theuid;
^
../../src/util/virutil.c:2412:17: error: 'thegid' may be used uninitialized in 
this function [-Werror=maybe-uninitialized]
*gidPtr = thegid;
^
../../src/util/virutil.c:2381:9: note: 'thegid' was declared here
gid_t thegid;
^
cc1: all warnings being treated as errors
Makefile:9167: recipe for target 'util/libvirt_util_la-virutil.lo' failed

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
src/util/virutil.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



ACK


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

Re: [libvirt] [PATCH] apibuild: Fix indentation

2015-06-08 Thread Ján Tomko
On Mon, Jun 08, 2015 at 11:18:57AM +0200, Jiri Denemark wrote:
 Signed-off-by: Jiri Denemark jdene...@redhat.com
 ---
  docs/apibuild.py | 48 
  1 file changed, 24 insertions(+), 24 deletions(-)
 

ACK

Jan


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

Re: [libvirt] the error is bug?

2015-06-08 Thread Michal Privoznik
On 29.05.2015 16:38, cloudbuglist wrote:
 Hi dear!
   Today I came across a problem, the following is a log and software versions.
 soft version:
 os:centos 6.5
 libvirt:0.10.29
 qemu:0.12.415
 
 
 2015-05-28 03:28:58.001+: 20919: error : 
 qemuDomainObjBeginJobInternal:843 : Timed out during operation: cannot 
 acquire state change lock
 2015-05-28 03:30:37.000+: 20918: warning : 
 qemuDomainObjBeginJobInternal:839 : Cannot start job (query, none) for domain 
 i-2-437-VM; current job is (query, none) owned by (20917, 0)
 2015-05-28 03:30:37.000+: 20918: error : 
 qemuDomainObjBeginJobInternal:843 : Timed out during operation: cannot 
 acquire state change lock
 2015-05-28 03:31:01.000+: 20919: warning : 
 qemuDomainObjBeginJobInternal:839 : Cannot start job (query, none) for domain 
 i-2-437-VM; current job is (query, none) owned by (20917, 0)
 2015-05-28 03:31:01.000+: 20919: error : 
 qemuDomainObjBeginJobInternal:843 : Timed out during operation: cannot 
 acquire state change lock
 2015-05-28 03:32:40.000+: 20921: warning : 
 qemuDomainObjBeginJobInternal:839 : Cannot start job (query, none) for domain 
 i-2-437-VM; current job is (query, none) owned by (20917, 0)
 2015-05-28 03:32:40.000+: 20921: error : 
 qemuDomainObjBeginJobInternal:843 : Timed out during operation: cannot 
 acquire state change lock
 2015-05-28 03:33:06.000+: 20918: warning : 
 qemuDomainObjBeginJobInternal:839 : Cannot start job (query, none) for domain 
 i-2-437-VM; current job is (query, none) owned by (20917, 0)
 2015-05-28 03:33:06.000+: 20918: error : 
 qemuDomainObjBeginJobInternal:843 : Timed out during operation: cannot 
 acquire state change lock
 2015-05-28 03:33:42.009+: 20916: error : virNetSocketReadWire:1194 : End 
 of file while reading data: Input/output error
 2015-05-28 03:34:02.000+: 20921: warning : 
 qemuDomainObjBeginJobInternal:839 : Cannot start job (query, none) for domain 
 i-2-437-VM; current job is (query, none) owned by (20917, 0)
 2015-05-28 03:34:02.000+: 20921: error : 
 qemuDomainObjBeginJobInternal:843 : Timed out during operation: cannot 
 acquire state change lock
 2015-05-28 03:34:19.001+: 20920: warning : 
 qemuDomainObjBeginJobInternal:839 : Cannot start job (query, none) for domain 
 i-2-437-VM; current job is (query, none) owned by (20917, 0)
 2015-05-28 03:34:19.001+: 20920: error : 
 qemuDomainObjBeginJobInternal:843 : Timed out during operation: cannot 
 acquire state change lock
 2015-05-28 03:34:43.384+: 20916: error : virNetSocketReadWire:1194 : End 
 of file while reading data: Input/output error
 2015-05-28 03:34:47.000+: 20918: warning : 
 qemuDomainObjBeginJobInternal:839 : Cannot start job (query, none) for domain 
 i-2-437-VM; current job is (query, none) owned by (20917, 0)
 2015-05-28 03:34:47.000+: 20918: error : 
 qemuDomainObjBeginJobInternal:843 : Timed out during operation: cannot 
 acquire state change lock
 2015-05-28 03:34:52.000+: 20920: warning : 
 qemuDomainObjBeginJobInternal:839 : Cannot start job (query, none) for domain 
 i-2-437-VM; current job is (query, none) owned by (20917, 0)
 2015-05-28 03:34:52.000+: 20920: error : 
 qemuDomainObjBeginJobInternal:843 : Timed out during operation: cannot 
 acquire state change lock
 2015-05-28 03:35:09.001+: 20921: warning : 
 qemuDomainObjBeginJobInternal:839 : Cannot start job (query, none) for domain 
 i-2-437-VM; current job is (query, none) owned by (20917, 0)
 2015-05-28 03:35:09.001+: 20921: error : 
 qemuDomainObjBeginJobInternal:843 : Timed out during operation: cannot 
 acquire state change lock

This usually means, that the other thread (20917) has locked the domain
for changes (or to be more technical, it set a job). If you attach gdb
onto the daemon and query what is the other thread doing, you'll get the
picture. Unfortunately, some operations on a domain can take ages to
finish. The other possibility could be, that a thread has set the job
and accessed an NFS backed storage which went stale. Or this can as well
be a bug. Hard to tell from only this info. Also - does this happen with
new libvirt? 0.10.29 is a bit old today.

Michal

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


Re: [libvirt] [PATCH 3/3] qemu: caps: Advertise arm 32-on-64 KVM option

2015-06-08 Thread Daniel P. Berrange
On Sat, Jun 06, 2015 at 07:06:42PM -0400, Cole Robinson wrote:
 On 05/28/2015 07:31 AM, Daniel P. Berrange wrote:
  On Thu, May 21, 2015 at 07:03:28PM -0400, Cole Robinson wrote:
  We need to use qemu-system-aarch64 to run armv7l KVM VMs on an aarch64
  host.
  ---
   src/qemu/qemu_capabilities.c | 42 
  ++
   1 file changed, 22 insertions(+), 20 deletions(-)
 
  diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
  index 1e7bddb..7181865 100644
  --- a/src/qemu/qemu_capabilities.c
  +++ b/src/qemu/qemu_capabilities.c
  @@ -723,19 +723,6 @@ virQEMUCapsFindBinaryForArch(virArch hostarch,
   return ret;
   }
   
  -
  -static bool
  -virQEMUCapsIsValidForKVM(virArch hostarch,
  - virArch guestarch)
  -{
  -if (hostarch == guestarch)
  -return true;
  -if (hostarch == VIR_ARCH_X86_64 
  -guestarch == VIR_ARCH_I686)
  -return true;
  -return false;
  -}
  -
   static int
   virQEMUCapsInitGuest(virCapsPtr caps,
virQEMUCapsCachePtr cache,
  @@ -747,6 +734,7 @@ virQEMUCapsInitGuest(virCapsPtr caps,
   char *binary = NULL;
   virQEMUCapsPtr qemubinCaps = NULL;
   virQEMUCapsPtr kvmbinCaps = NULL;
  +bool native_kvm, x86_32on64_kvm, arm_32on64_kvm;
   int ret = -1;
   
   /* Check for existence of base emulator, or alternate base
  @@ -764,16 +752,30 @@ virQEMUCapsInitGuest(virCapsPtr caps,
   
   /* qemu-kvm/kvm binaries can only be used if
*  - host  guest arches match
  - * Or
  - *  - hostarch is x86_64 and guest arch is i686
  - * The latter simply needs -cpu qemu32
  + *  - hostarch is x86_64 and guest arch is i686 (needs -cpu qemu32)
  + *  - hostarch is aarch64 and guest arch is armv7l (needs -cpu 
  aarch64=off)
*/
  -if (virQEMUCapsIsValidForKVM(hostarch, guestarch)) {
  -const char *const kvmbins[] = { /usr/libexec/qemu-kvm, /* RHEL 
  */
  -qemu-kvm, /* Fedora */
  -kvm }; /* Upstream .spec */
  +native_kvm = (hostarch == guestarch);
  +x86_32on64_kvm = (hostarch == VIR_ARCH_X86_64 
  +guestarch == VIR_ARCH_I686);
  +arm_32on64_kvm = (hostarch == VIR_ARCH_AARCH64 
  +guestarch == VIR_ARCH_ARMV7L);
  +
  +if (native_kvm || x86_32on64_kvm || arm_32on64_kvm) {
  +const char *kvmbins[] = {
  +/usr/libexec/qemu-kvm, /* RHEL */
  +qemu-kvm, /* Fedora */
  +kvm, /* Debian/Ubuntu */
  +NULL,
  +};
  +
  +if (arm_32on64_kvm)
  +kvmbins[3] = qemu-system-aarch64;
  
  I'm unclear why you need to be adding this. We don't need it for
  the equivalent i686 with qemu-system-x86_64, as the earlier call
  to virQEMUCapsFindBinaryForArch() will already return the binary
  qemu-system-x86_64. IIUC, it should have returned the binary
  qemu-system-aarch64 too, so this just seems to duplicate the
  check for that binary.
 
 We need this in the case you are running on an aarch64 host and have both
 qemu-system-arm and qemu-system-aarch64 installed. In this case, when you want
 to use KVM for arm32, you _have_ to use qemu-system-aarch64, qemu-system-arm
 does not work. What you suggest would mean that qemu-system-arm is grabbed
 from the caps cache.
 
 x86 doesn't have this problem because qemu-system-i386, qemu-system-x86_64 and
 by extension qemu-kvm can all be used to do 32-on-64 KVM.

Ok, I think we need to have this explained in the code comments, because
that is none obvious from reading the code  we don't want to be wondering
why we did this when looking at the code again in a year :-)

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

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


[libvirt] [PATCH 1/2] utils: Return proper value for virGet{User, Group}ID

2015-06-08 Thread Michal Privoznik
These two functions are used to translate user or group name into
a numerical ID. Depending on platform we are building for, we
have an implementation for UNIX-like systems, and a stub
implementation for Windows. While the former returns a negative
value on error, the latter simply reports an error (saying
something about missing implementation) and returns the value of
zero. This makes the caller think function did succeed and passed
variable had been set to the correct value. Well, it was not.
Even compiler spots this when compiling for win32:

  CC   util/libvirt_util_la-virutil.lo
../../src/util/virutil.c: In function 'virParseOwnershipIds':
../../src/util/virutil.c:2410:17: error: 'theuid' may be used uninitialized in 
this function [-Werror=maybe-uninitialized]
 *uidPtr = theuid;
 ^
../../src/util/virutil.c:2380:9: note: 'theuid' was declared here
 uid_t theuid;
 ^
../../src/util/virutil.c:2412:17: error: 'thegid' may be used uninitialized in 
this function [-Werror=maybe-uninitialized]
 *gidPtr = thegid;
 ^
../../src/util/virutil.c:2381:9: note: 'thegid' was declared here
 gid_t thegid;
 ^
cc1: all warnings being treated as errors
Makefile:9167: recipe for target 'util/libvirt_util_la-virutil.lo' failed

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
 src/util/virutil.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/virutil.c b/src/util/virutil.c
index e479cce..cddc78a 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -1316,7 +1316,7 @@ int virGetUserID(const char *name ATTRIBUTE_UNUSED,
 virReportError(VIR_ERR_INTERNAL_ERROR,
%s, _(virGetUserID is not available));
 
-return 0;
+return -1;
 }
 
 
@@ -1326,7 +1326,7 @@ int virGetGroupID(const char *name ATTRIBUTE_UNUSED,
 virReportError(VIR_ERR_INTERNAL_ERROR,
%s, _(virGetGroupID is not available));
 
-return 0;
+return -1;
 }
 
 int
-- 
2.3.6

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


[libvirt] [PATCH v2] utiltest: Use int8_t instead of char.

2015-06-08 Thread Michal Privoznik
Not every architecture out there has 'char' signed by default.
For instance, my arm box has it unsigned by default:

  $ gcc -dM -E -  /dev/null | grep __CHAR_UNSIGNED__
  #define __CHAR_UNSIGNED__ 1

Therefore, after 65c61e50 the test if failing for me. Problem is,
we are trying to assign couple of negative values into char
assuming some will overflow and some don't. That can't be the
case if 'char' is unsigned by default. Lets use more explicit types
instead: int8_t and uint8_t where is no ambiguity.

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
 tests/utiltest.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/utiltest.c b/tests/utiltest.c
index 3a1f8eb..98c689d 100644
--- a/tests/utiltest.c
+++ b/tests/utiltest.c
@@ -184,8 +184,8 @@ static int
 testOverflowCheckMacro(const void *data ATTRIBUTE_UNUSED)
 {
 long long tmp;
-unsigned char luchar;
-char lchar;
+uint8_t luchar;
+int8_t lchar;
 
 TEST_OVERFLOW(luchar, 254, false);
 TEST_OVERFLOW(luchar, 255, false);
-- 
2.3.6

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


[libvirt] [PATCH 0/2] Couple of unrelated fixes

2015-06-08 Thread Michal Privoznik
*** BLURB HERE ***

Michal Privoznik (2):
  utils: Return proper value for virGet{User,Group}ID
  utiltest: Don't assume 'char' is always signed

 src/util/virutil.c | 4 ++--
 tests/utiltest.c   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

-- 
2.3.6

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


[libvirt] [PATCH] util: process: fix build on FreeBSD

2015-06-08 Thread Roman Bogorodskiy
Commit 825df8c3 refactored virProcess{Set,Get}Affinity routines,
however broke BSD implementation because of the incorrect variable
name. Fix build by using a proper variable name.

Pushing as trivial and build break fix.
---
 src/util/virprocess.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index a38cb75..59598ed 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -566,7 +566,7 @@ virProcessGetAffinity(pid_t pid)
 return NULL;
 }
 
-if (!(*map = virBitmapNew(sizeof(mask) * 8)))
+if (!(ret = virBitmapNew(sizeof(mask) * 8)))
 return NULL;
 
 for (i = 0; i  sizeof(mask) * 8; i++)
-- 
2.4.2

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


Re: [libvirt] Canging bridge names on live migration

2015-06-08 Thread Michal Privoznik
On 03.06.2015 13:18, seitan wrote:
 Hello,
 i wonder, if there's a possibility to change a name of a shared interface in
 virtual machine config, while doing migration.
 The problem is:
 hypervisor1 (source) uses shared interface name  br0.
 hypervisor2 (target) uses shared interface name br500.
 Live migration fails, because target hypervisor does not have br0 interface.
 Thank you

Yes it is possible. The migration APIs have an argument @xmlin where you
can specify new XML definition for the domain on the destination. It
serves exactly this purpose where the environment there is slightly
different to the source.

Michal

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


Re: [libvirt] [PATCH 1/2] utils: Return proper value for virGet{User, Group}ID

2015-06-08 Thread Peter Krempa
On Mon, Jun 08, 2015 at 10:47:05 +0200, Martin Kletzander wrote:
 On Mon, Jun 08, 2015 at 10:43:38AM +0200, Michal Privoznik wrote:
 These two functions are used to translate user or group name into
 a numerical ID. Depending on platform we are building for, we
 have an implementation for UNIX-like systems, and a stub
 implementation for Windows. While the former returns a negative
 value on error, the latter simply reports an error (saying
 something about missing implementation) and returns the value of
 zero. This makes the caller think function did succeed and passed
 variable had been set to the correct value. Well, it was not.
 Even compiler spots this when compiling for win32:
 
   CC   util/libvirt_util_la-virutil.lo
 ../../src/util/virutil.c: In function 'virParseOwnershipIds':
 ../../src/util/virutil.c:2410:17: error: 'theuid' may be used uninitialized 
 in this function [-Werror=maybe-uninitialized]
  *uidPtr = theuid;
  ^
 ../../src/util/virutil.c:2380:9: note: 'theuid' was declared here
  uid_t theuid;
  ^
 ../../src/util/virutil.c:2412:17: error: 'thegid' may be used uninitialized 
 in this function [-Werror=maybe-uninitialized]
  *gidPtr = thegid;
  ^
 ../../src/util/virutil.c:2381:9: note: 'thegid' was declared here
  gid_t thegid;
  ^
 cc1: all warnings being treated as errors
 Makefile:9167: recipe for target 'util/libvirt_util_la-virutil.lo' failed
 
 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  src/util/virutil.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 
 ACK

I actually pushed the same patch a while ago.

Peter


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

[libvirt] [PATCH] apibuild: Fix indentation

2015-06-08 Thread Jiri Denemark
Signed-off-by: Jiri Denemark jdene...@redhat.com
---
 docs/apibuild.py | 48 
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/docs/apibuild.py b/docs/apibuild.py
index 9fa9361..18278db 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -1356,32 +1356,32 @@ class CParser:
 token = self.token()
 return token
 elif token[0] == name:
-self.cleanupComment()
-if name is not None:
-if self.comment is not None:
-comment = string.strip(self.comment)
-self.comment = None
-self.enums.append((name, value, comment))
-name = token[1]
-comment = 
+self.cleanupComment()
+if name is not None:
+if self.comment is not None:
+comment = string.strip(self.comment)
+self.comment = None
+self.enums.append((name, value, comment))
+name = token[1]
+comment = 
+token = self.token()
+if token[0] == op and token[1][0] == =:
+value = 
+if len(token[1])  1:
+value = token[1][1:]
 token = self.token()
-if token[0] == op and token[1][0] == =:
-value = 
-if len(token[1])  1:
-value = token[1][1:]
-token = self.token()
-while token[0] != sep or (token[1] != ',' and
-  token[1] != '}'):
-value = value + token[1]
-token = self.token()
-else:
-try:
-value = %d % (int(value) + 1)
-except:
-self.warning(Failed to compute value of enum %s 
% (name))
-value=
-if token[0] == sep and token[1] == ,:
+while token[0] != sep or (token[1] != ',' and
+  token[1] != '}'):
+value = value + token[1]
 token = self.token()
+else:
+try:
+value = %d % (int(value) + 1)
+except:
+self.warning(Failed to compute value of enum %s % 
(name))
+value=
+if token[0] == sep and token[1] == ,:
+token = self.token()
 else:
 token = self.token()
 return token
-- 
2.4.2

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


[libvirt] [python PATCH 2/2] Provide symbolic names for typed parameters

2015-06-08 Thread Jiri Denemark
https://bugzilla.redhat.com/show_bug.cgi?id=1222795

Signed-off-by: Jiri Denemark jdene...@redhat.com
---
 generator.py | 8 
 1 file changed, 8 insertions(+)

diff --git a/generator.py b/generator.py
index 676243c..2fc838c 100755
--- a/generator.py
+++ b/generator.py
@@ -10,6 +10,7 @@ enums = {} # { enumType: { enumConstant: enumValue } }
 lxc_enums = {} # { enumType: { enumConstant: enumValue } }
 qemu_enums = {} # { enumType: { enumConstant: enumValue } }
 event_ids = []
+params = [] # [ (parameName, paramValue)... ]
 
 import os
 import sys
@@ -134,6 +135,9 @@ class docParser(xml.sax.handler.ContentHandler):
 lxc_enum(attrs['type'],attrs['name'],attrs['value'])
 elif attrs['file'] == libvirt-qemu:
 qemu_enum(attrs['type'],attrs['name'],attrs['value'])
+elif tag == macro:
+if string in attrs:
+params.append((attrs['name'], attrs['string']))
 
 def end(self, tag):
 if debug:
@@ -1881,6 +1885,10 @@ def buildWrappers(module):
 classes.write(%s = %s\n % (name,value))
 classes.write(\n)
 
+classes.write(# typed parameter names\n)
+for name, value in params:
+classes.write(%s = \%s\\n % (name, value))
+
 classes.close()
 
 def qemuBuildWrappers(module):
-- 
2.4.2

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


[libvirt] [(python) PATCH 0/2] Provide symbolic names for typed parameters

2015-06-08 Thread Jiri Denemark
libvirt:

Jiri Denemark (1):
  apibuild: Generate macro/@string attribute

 docs/apibuild.py | 47 ---
 1 file changed, 28 insertions(+), 19 deletions(-)

libvirt-python:

Jiri Denemark (1):
  Provide symbolic names for typed parameters

 generator.py | 8 
 1 file changed, 8 insertions(+)

-- 
2.4.2

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


Re: [libvirt] [PATCH 2/2] utiltest: Don't assume 'char' is always signed

2015-06-08 Thread Peter Krempa
On Mon, Jun 08, 2015 at 10:43:39 +0200, Michal Privoznik wrote:
 Not every architecture out there has 'char' signed by default.
 For instance, my arm box has it unsigned by default:
 
   $ gcc -dM -E -  /dev/null | grep __CHAR_UNSIGNED__
   #define __CHAR_UNSIGNED__ 1
 
 Therefore, after 65c61e50 the test if failing for me. Problem is,
 we are trying to assign couple of negative values into char
 assuming some will overflow and some don't. That can't be the
 case if 'char' is unsigned by default.
 
 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  tests/utiltest.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/tests/utiltest.c b/tests/utiltest.c
 index 3a1f8eb..9eb7fb6 100644
 --- a/tests/utiltest.c
 +++ b/tests/utiltest.c
 @@ -185,7 +185,7 @@ testOverflowCheckMacro(const void *data ATTRIBUTE_UNUSED)
  {
  long long tmp;
  unsigned char luchar;
 -char lchar;
 +signed char lchar;

I actually did not know that without explicit specification char may be
signed or unsigned. Anyways, since char is not defined I'd rather change
the type to uint8_t and int8_t.


Peter


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

[libvirt] [PATCH 1/2] apibuild: Generate macro/@string attribute

2015-06-08 Thread Jiri Denemark
If a macro has a string value, the @string attribute will contain the
value. Otherwise @string attribute will be missing.

For example, the following macro definition from libvirt-domain.h:

 /**
  * VIR_MIGRATE_PARAM_URI:
  * ...
  */
 # define VIR_MIGRATE_PARAM_URI   migrate_uri

will result in

 macro name='VIR_MIGRATE_PARAM_URI' file='libvirt-domain' string='migrate_uri'
   info![CDATA[...]]/info
 /macro

https://bugzilla.redhat.com/show_bug.cgi?id=1229199

Signed-off-by: Jiri Denemark jdene...@redhat.com
---
 docs/apibuild.py | 47 ---
 1 file changed, 28 insertions(+), 19 deletions(-)

diff --git a/docs/apibuild.py b/docs/apibuild.py
index 18278db..d93d1d6 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -1028,9 +1028,12 @@ class CParser:
 name = string.split(name, '(') [0]
 except:
 pass
-info = self.parseMacroComment(name, not self.is_header)
+strValue = None
+if len(lst) == 1 and lst[0][0] == '' and lst[0][-1] == '':
+strValue = lst[0][1:-1]
+(args, desc) = self.parseMacroComment(name, not self.is_header)
 self.index_add(name, self.filename, not self.is_header,
-macro, info)
+   macro, (args, desc, strValue))
 return token
 
 #
@@ -2144,24 +2147,30 @@ class docBuilder:
 
 def serialize_macro(self, output, name):
 id = self.idx.macros[name]
-output.write(macro name='%s' file='%s'\n % (name,
+output.write(macro name='%s' file='%s' % (name,
  self.modulename_file(id.header)))
-if id.info is not None:
-try:
-(args, desc) = id.info
-if desc is not None and desc != :
-output.write(  info![CDATA[%s]]/info\n % 
(desc))
-self.indexString(name, desc)
-for arg in args:
-(name, desc) = arg
-if desc is not None and desc != :
-output.write(  arg name='%s' info='%s'/\n % (
- name, escape(desc)))
-self.indexString(name, desc)
-else:
-output.write(  arg name='%s'/\n % (name))
-except:
-pass
+if id.info is None:
+args = []
+desc = None
+strValue = None
+else:
+(args, desc, strValue) = id.info
+
+if strValue is not None:
+output.write( string='%s' % strValue)
+output.write(\n)
+
+if desc is not None and desc != :
+output.write(  info![CDATA[%s]]/info\n % (desc))
+self.indexString(name, desc)
+for arg in args:
+(name, desc) = arg
+if desc is not None and desc != :
+output.write(  arg name='%s' info='%s'/\n % (
+ name, escape(desc)))
+self.indexString(name, desc)
+else:
+output.write(  arg name='%s'/\n % (name))
 output.write(/macro\n)
 
 def serialize_union(self, output, field, desc):
-- 
2.4.2

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


[libvirt] poor virtio-scsi performance

2015-06-08 Thread Vasiliy Tolstov
Hi all!

I suspected poor performance of virtio-scsi driver.
I did a few tests:
   Host machine: linux 3.19.1, QEMU emulator version 2.3.0
   Guest machine: linux 4.0.4

   part of domain xml:
emulator/usr/bin/kvm/emulator
disk type='block' device='disk'
  driver name='qemu' type='raw' cache='none' io='native' discard='unmap'/
  source dev='/dev/ram0'/
  backingStore/
  target dev='sda' bus='scsi'/
  alias name='scsi0-0-0-1'/
  address type='drive' controller='0' bus='0' target='0' unit='1'/
/disk

/dev/ram0 I got by running `modprobe brd rd_size=$((5*1024*1024))` on
host machine.

fio conf:
  [readtest]
  blocksize=4k
  filename=/dev/sdb (/dev/ram0 whe test from host machine)
  rw=randread
  direct=1
  buffered=0
  ioengine=libaio
  iodepth=32


results:
  from host:
bw=1594.6MB/s, iops=408196, clat=76usec
  from guest:
bw=398MB/s, iops=99720, clat=316usec

Both host and guest system I boot with `scsi_mod.use_blk_mq=Y`.

Why difference in 4 times?!

-- 
Vasiliy Tolstov,
e-mail: v.tols...@selfip.ru

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


Re: [libvirt] [PATCH v2] utiltest: Use int8_t instead of char.

2015-06-08 Thread Peter Krempa
On Mon, Jun 08, 2015 at 12:58:06 +0200, Michal Privoznik wrote:
 Not every architecture out there has 'char' signed by default.
 For instance, my arm box has it unsigned by default:
 
   $ gcc -dM -E -  /dev/null | grep __CHAR_UNSIGNED__
   #define __CHAR_UNSIGNED__ 1
 
 Therefore, after 65c61e50 the test if failing for me. Problem is,
 we are trying to assign couple of negative values into char
 assuming some will overflow and some don't. That can't be the
 case if 'char' is unsigned by default. Lets use more explicit types
 instead: int8_t and uint8_t where is no ambiguity.
 
 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  tests/utiltest.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

ACK,

Peter


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

[libvirt] [PATCH] virNumaSetPagePoolSize: Produce friendlier error message

2015-06-08 Thread Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1224587

The function takes two important arguments (among many others): @node
and @page_size. From these two a path under /sys is constructed. The
path is then used to read and write the desired size of huge pages
pool. However, if the path does not exists due to either @node or
@page_size having nonexistent value (e.g. there's no such NUMA node or
no page size like -2), an cryptic error message is produced:

  virsh # allocpages --pagesize 2049 --pagecount 8 --cellno -2
  error: Failed to open file 
'/sys/devices/system/node/node-2/hugepages/hugepages-2049kB/nr_hugepages': No 
such file or directory

Add two more checks to catch this and therefore produce much more
friendlier error messages.

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
 src/util/virnuma.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 669192a..5807d8f 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -849,9 +849,27 @@ virNumaSetPagePoolSize(int node,
 goto cleanup;
 }
 
+if (node != -1  !virNumaNodeIsAvailable(node)) {
+virReportError(VIR_ERR_OPERATION_FAILED,
+   _(NUMA node %d is not available),
+   node);
+goto cleanup;
+}
+
 if (virNumaGetHugePageInfoPath(nr_path, node, page_size, nr_hugepages) 
 0)
 goto cleanup;
 
+if (!virFileExists(nr_path)) {
+/* Strictly speaking, @nr_path contains both NUMA node and page size.
+ * So if it doesn't exist it can be due to any of those two is wrong.
+ * However, the existence of the node was checked a few lines above, so
+ * it can be only page size here. */
+virReportError(VIR_ERR_OPERATION_FAILED,
+   _(page size %u not available),
+   page_size);
+goto cleanup;
+}
+
 /* Firstly check, if there's anything for us to do */
 if (virFileReadAll(nr_path, 1024, nr_buf)  0)
 goto cleanup;
-- 
2.3.6

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


Re: [libvirt] [Qemu-devel] poor virtio-scsi performance

2015-06-08 Thread Alexandre DERUMIER
Hi,
if you want to use multiqueues in guest, you need to enabled it on virtio-scsi 
controller.

controller type='scsi' index='0' model='virtio-scsi' num_queues='8'/

for example.


- Mail original -
De: Vasiliy Tolstov v.tols...@selfip.ru
À: qemu-devel qemu-de...@nongnu.org, libvir-list@redhat.com
Envoyé: Lundi 8 Juin 2015 12:30:59
Objet: [Qemu-devel] poor virtio-scsi performance

Hi all! 

I suspected poor performance of virtio-scsi driver. 
I did a few tests: 
Host machine: linux 3.19.1, QEMU emulator version 2.3.0 
Guest machine: linux 4.0.4 

part of domain xml: 
emulator/usr/bin/kvm/emulator 
disk type='block' device='disk' 
driver name='qemu' type='raw' cache='none' io='native' discard='unmap'/ 
source dev='/dev/ram0'/ 
backingStore/ 
target dev='sda' bus='scsi'/ 
alias name='scsi0-0-0-1'/ 
address type='drive' controller='0' bus='0' target='0' unit='1'/ 
/disk 

/dev/ram0 I got by running `modprobe brd rd_size=$((5*1024*1024))` on 
host machine. 

fio conf: 
[readtest] 
blocksize=4k 
filename=/dev/sdb (/dev/ram0 whe test from host machine) 
rw=randread 
direct=1 
buffered=0 
ioengine=libaio 
iodepth=32 


results: 
from host: 
bw=1594.6MB/s, iops=408196, clat=76usec 
from guest: 
bw=398MB/s, iops=99720, clat=316usec 

Both host and guest system I boot with `scsi_mod.use_blk_mq=Y`. 

Why difference in 4 times?! 

-- 
Vasiliy Tolstov, 
e-mail: v.tols...@selfip.ru 

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

[libvirt] [PATCH] schema: use arch list from basictypes for os arch attribute

2015-06-08 Thread James Cowgill
I see no reason to duplicate this list of architectures. This also allows
more guest architectures to be used with libvirt (like the mips64el qemu
machine I am trying to run).

Signed-off-by: James Cowgill james...@cowgill.org.uk
---
 docs/schemas/domaincommon.rng | 26 ++
 1 file changed, 6 insertions(+), 20 deletions(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 7c6fa5c..fc28fb3 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -331,7 +331,9 @@
   define name=ostypehvm
 element name=type
   optional
-ref name=archList/
+attribute name=arch
+  ref name=archnames/
+/attribute
   /optional
   optional
 attribute name=machine
@@ -344,29 +346,13 @@
 /element
   /define
 
-  define name=archList
-attribute name=arch
-  choice
-valuearmv7l/value
-valueaarch64/value
-valuei686/value
-valuex86_64/value
-valuemips/value
-valueppc/value
-valueppc64/value
-valueppc64le/value
-values390/value
-values390x/value
-valuesparc/value
-  /choice
-/attribute
-  /define
-
   define name=osexe
 element name=os
   element name=type
 optional
-  ref name=archList/
+  attribute name=arch
+ref name=archnames/
+  /attribute
 /optional
 valueexe/value
   /element
-- 
2.1.4


signature.asc
Description: This is a digitally signed message part
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] qemu: implement address for isa-serial

2015-06-08 Thread James Cowgill
I needed to specify the iobase address for certain exotic mips configurations.

Signed-off-by: James Cowgill james...@cowgill.org.uk
---
 src/qemu/qemu_command.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 61faa57..e1d53c2 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2693,6 +2693,10 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
   info-addr.ccw.cssid,
   info-addr.ccw.ssid,
   info-addr.ccw.devno);
+} else if (info-type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) {
+virBufferAsprintf(buf, ,iobase=0x%x,irq=0x%x,
+  info-addr.isa.iobase,
+  info-addr.isa.irq);
 }
 
 ret = 0;
@@ -10950,11 +10954,15 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
 break;
 
 case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
-if (serial-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
+if (serial-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE 
+serial-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
-   _(no addresses are supported for isa-serial));
+   _(isa-serial requires address of isa type));
 goto error;
 }
+
+if (qemuBuildDeviceAddressStr(cmd, def, serial-info, qemuCaps) 
 0)
+goto error;
 break;
 
 case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
-- 
2.1.4


signature.asc
Description: This is a digitally signed message part
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [Qemu-devel] qemu commit 65207c59 broke libvirt's capability retrieval (apparently)

2015-06-08 Thread Markus Armbruster
Laszlo Ersek ler...@redhat.com writes:

 On 06/05/15 23:47, Eric Blake wrote:
 On 06/05/2015 03:42 PM, Laszlo Ersek wrote:
 
 I found this qemu commit, ie.

 commit 65207c59d99f2260c5f1d3b9c491146616a522aa
 Author: Markus Armbruster arm...@redhat.com
 Date:   Thu Mar 5 14:35:26 2015 +0100

 monitor: Drop broken, unused asynchronous command interface

 with bisection. Unfortunately, the bisection was extremely painful,
 because between a working version and today's pull, part of the
 qemu history was uncompileable. It was ultimately fixed with
 
 Which tells me that it's not individual capabilities that are
 broken by qemu 65207c59, but the entire libvirt capability
 retrieval. Apparently libvirt is one user of that async monitor
 interface. (The message on commit 65207c59 itself mentions
 qmp_capabilities.)
 
 Libvirt doesn't use async capabilities, so much as Markus accidentally
 broke the QMP protocol by completely ditching support for the id
 member that libvirt uses on every synchronous QMP command.  Several
 threads already exist on the matter:
 
 https://lists.gnu.org/archive/html/qemu-devel/2015-06/msg01806.html
 https://lists.gnu.org/archive/html/qemu-devel/2015-06/msg01488.html
 

 Fantastic, I was wondering how I could remedy this (without having to
 rebase my work in progress onto 65207c59^). Your second link seems to
 have a fix I can apply locally, temporarily. (Hm, well, your first link
 does too, just with different comments, as you said.)

 Many thanks!

Fixed in current master: commit 779cec4.  Sorry for the inconvenience!

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


Re: [libvirt] [PATCH 3/3] rpc: add testing of RPC JSON (de)serialization

2015-06-08 Thread Martin Kletzander

On Fri, Jun 05, 2015 at 09:47:45AM +0100, Daniel P. Berrange wrote:

The virNetServer class has the ability to serialize its state
to a JSON file, and then re-load that data after an in-place
execve() call to re-connect to active file handles. This data
format is critical ABI that must have compatibility across
releases, so it should be tested...
---
src/libvirt_remote.syms|   1 +
src/rpc/virnetserver.c |   4 +-
src/rpc/virnetserver.h |   3 +
src/rpc/virnetserverclient.c   |  13 +-
src/rpc/virnetserverservice.c  |   6 +-
tests/Makefile.am  |   7 +
tests/virnetserverdata/README  |  14 +
.../virnetserverdata/input-data-anon-clients.json  |  63 +
tests/virnetserverdata/input-data-initial.json |  62 +
.../virnetserverdata/output-data-anon-clients.json |  63 +
tests/virnetserverdata/output-data-initial.json|  63 +
tests/virnetservertest.c   | 290 +
12 files changed, 579 insertions(+), 10 deletions(-)
create mode 100644 tests/virnetserverdata/README
create mode 100644 tests/virnetserverdata/input-data-anon-clients.json
create mode 100644 tests/virnetserverdata/input-data-initial.json
create mode 100644 tests/virnetserverdata/output-data-anon-clients.json
create mode 100644 tests/virnetserverdata/output-data-initial.json
create mode 100644 tests/virnetservertest.c

diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms
index 950e56e..bdd68f6 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -77,6 +77,7 @@ xdr_virNetMessageError;


# rpc/virnetserver.h
+virNetServerAddClient;
virNetServerAddProgram;
virNetServerAddService;
virNetServerAddShutdownInhibition;
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 42427dc..091a1dc 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -259,8 +259,8 @@ static int 
virNetServerDispatchNewMessage(virNetServerClientPtr client,
}


-static int virNetServerAddClient(virNetServerPtr srv,
- virNetServerClientPtr client)
+int virNetServerAddClient(virNetServerPtr srv,
+  virNetServerClientPtr client)
{
virObjectLock(srv);

diff --git a/src/rpc/virnetserver.h b/src/rpc/virnetserver.h
index 8c5ae07..4b452be 100644
--- a/src/rpc/virnetserver.h
+++ b/src/rpc/virnetserver.h
@@ -79,6 +79,9 @@ int virNetServerAddService(virNetServerPtr srv,
   virNetServerServicePtr svc,
   const char *mdnsEntryName);

+int virNetServerAddClient(virNetServerPtr srv,
+  virNetServerClientPtr client);
+
int virNetServerAddProgram(virNetServerPtr srv,
   virNetServerProgramPtr prog);

diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index 34c1994..0e3a71f 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -536,13 +536,14 @@ virJSONValuePtr 
virNetServerClientPreExecRestart(virNetServerClientPtr client)
goto error;
}

-if (client-privateData  client-privateDataPreExecRestart 
-!(child = client-privateDataPreExecRestart(client, 
client-privateData)))
-goto error;
+if (client-privateData  client-privateDataPreExecRestart) {
+if (!(child = client-privateDataPreExecRestart(client, 
client-privateData)))
+goto error;

-if (virJSONValueObjectAppend(object, privateData, child)  0) {
-virJSONValueFree(child);
-goto error;
+if (virJSONValueObjectAppend(object, privateData, child)  0) {
+virJSONValueFree(child);
+goto error;
+}
}

virObjectUnlock(client);
diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c
index d3cf31a..4df26cb 100644
--- a/src/rpc/virnetserverservice.c
+++ b/src/rpc/virnetserverservice.c
@@ -303,12 +303,15 @@ virNetServerServicePtr virNetServerServiceNewFD(int fd,

/* IO callback is initially disabled, until we're ready
 * to deal with incoming clients */
+virObjectRef(svc);
if (virNetSocketAddIOCallback(svc-socks[i],
  0,
  virNetServerServiceAccept,
  svc,
-  virObjectFreeCallback)  0)
+  virObjectFreeCallback)  0) {
+virObjectUnref(svc);
goto error;
+}
}


@@ -388,7 +391,6 @@ virNetServerServicePtr 
virNetServerServiceNewPostExecRestart(virJSONValuePtr obj
  svc,
  virObjectFreeCallback)  0) {
virObjectUnref(svc);
-virObjectUnref(sock);
goto error;
}
}


I forgot to say that these hunks 

Re: [libvirt] [PATCH 3/3] rpc: add testing of RPC JSON (de)serialization

2015-06-08 Thread Martin Kletzander

On Fri, Jun 05, 2015 at 09:47:45AM +0100, Daniel P. Berrange wrote:

The virNetServer class has the ability to serialize its state
to a JSON file, and then re-load that data after an in-place
execve() call to re-connect to active file handles. This data
format is critical ABI that must have compatibility across
releases, so it should be tested...
---
src/libvirt_remote.syms|   1 +
src/rpc/virnetserver.c |   4 +-
src/rpc/virnetserver.h |   3 +
src/rpc/virnetserverclient.c   |  13 +-
src/rpc/virnetserverservice.c  |   6 +-
tests/Makefile.am  |   7 +
tests/virnetserverdata/README  |  14 +
.../virnetserverdata/input-data-anon-clients.json  |  63 +
tests/virnetserverdata/input-data-initial.json |  62 +
.../virnetserverdata/output-data-anon-clients.json |  63 +
tests/virnetserverdata/output-data-initial.json|  63 +
tests/virnetservertest.c   | 290 +
12 files changed, 579 insertions(+), 10 deletions(-)
create mode 100644 tests/virnetserverdata/README
create mode 100644 tests/virnetserverdata/input-data-anon-clients.json
create mode 100644 tests/virnetserverdata/input-data-initial.json
create mode 100644 tests/virnetserverdata/output-data-anon-clients.json
create mode 100644 tests/virnetserverdata/output-data-initial.json
create mode 100644 tests/virnetservertest.c


[...]

+testCreateServer(const char *host, int family)
+{
+virNetServerPtr srv = NULL;
+virNetServerServicePtr svc1 = NULL, svc2 = NULL;
+virNetServerClientPtr cln1 = NULL, cln2 = NULL;
+virNetSocketPtr sk1 = NULL, sk2 = NULL;
+int fdclient[2];
+
+if (socketpair(PF_UNIX, SOCK_STREAM, 0, fdclient)  0) {
+virReportSystemError(errno, %s,
+ Cannot create socket pair);
+goto cleanup;
+}
+
+if (!(srv = virNetServerNew(10, 50, 5, 100, 10,
+120, 5, true,
+libvirtTest,


It would be nice to have this generate JSON even if compiling without
AVAHI.  This will now fail.


+NULL,
+NULL,
+NULL,
+NULL)))
+goto error;
+
+if (!(svc1 = virNetServerServiceNewTCP(host,
+   NULL,
+   family,
+   VIR_NET_SERVER_SERVICE_AUTH_NONE,
+# ifdef WITH_GNUTLS
+   NULL,
+# endif
+   true,
+   5,
+   2)))
+goto error;
+
+if (!(svc2 = virNetServerServiceNewTCP(host,
+   NULL,
+   VIR_NET_SERVER_SERVICE_AUTH_POLKIT,
+   family,


Compiler won't find it, but you switched the lines here ^^.


+static int testExecRestart(const void *opaque)
+{
+int ret = -1;
+virNetServerPtr srv = NULL;
+const struct testExecRestartData *data = opaque;
+char *infile = NULL, *outfile = NULL;
+char *injsonstr = NULL, *outjsonstr = NULL;
+virJSONValuePtr injson = NULL, outjson = NULL;
+int fdclient[2] = { -1, -1 }, fdserver[2] = { -1, -1 };
+
+if (socketpair(PF_UNIX, SOCK_STREAM, 0, fdclient)  0) {
+virReportSystemError(errno, %s,
+ Cannot create socket pair);
+goto cleanup;
+}
+
+if (socketpair(PF_UNIX, SOCK_STREAM, 0, fdserver)  0) {
+virReportSystemError(errno, %s,
+ Cannot create socket pair);
+goto cleanup;
+}
+
+/* We're blindly assuming the test case isn't using
+ * fds 100-103 for something else, which is probably
+ * fairly reasonable in general
+ */
+dup2(fdserver[0], 100);
+dup2(fdserver[1], 101);
+dup2(fdclient[0], 102);
+dup2(fdclient[1], 103);
+
+if (virAsprintf(infile, %s/virnetserverdata/input-data-%s.json,
+abs_srcdir, data-jsonfile)  0)
+goto cleanup;
+
+if (virAsprintf(outfile, %s/virnetserverdata/output-data-%s.json,
+abs_srcdir, data-jsonfile)  0)
+goto cleanup;
+
+if (virFileReadAll(infile, 8192, injsonstr)  0)
+goto cleanup;
+
+if (!(injson = virJSONValueFromString(injsonstr)))
+goto cleanup;
+
+if (!(srv = virNetServerNewPostExecRestart(injson,
+   NULL, NULL, NULL,
+   NULL, NULL)))
+goto cleanup;
+
+if (!(outjson = virNetServerPreExecRestart(srv)))
+goto cleanup;
+
+if (!(outjsonstr = 

Re: [libvirt] [PATCH 1/3] rpc: allow selection of TCP address family

2015-06-08 Thread Martin Kletzander

On Fri, Jun 05, 2015 at 09:47:43AM +0100, Daniel P. Berrange wrote:

By default, getaddrinfo() will return addresses for both
IPv4 and IPv6 if both protocols are enabled, and so the
RPC code will listen/connect to both protocols too. There
may be cases where it is desirable to restrict this to
just one of the two protocols, so add an 'int family'
parameter to all the TCP related APIs.

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
daemon/libvirtd.c |  2 ++
src/libxl/libxl_migration.c   |  8 ++--
src/qemu/qemu_migration.c |  4 +++-
src/remote/remote_driver.c|  3 ++-
src/rpc/virnetclient.c| 12 +---
src/rpc/virnetclient.h|  4 +++-
src/rpc/virnetserverservice.c |  2 ++
src/rpc/virnetserverservice.h |  1 +
src/rpc/virnetsocket.c|  8 +++-
src/rpc/virnetsocket.h|  3 +++
tests/virnetsockettest.c  |  8 ++--
11 files changed, 44 insertions(+), 11 deletions(-)



ACK


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

[libvirt] [PATCH 1/2] docs: Adjust Disk storage rng

2015-06-08 Thread John Ferlan
Currently the grammar uses none for a valid Disk Storage Pool
format type; however, virStoragePoolFormatDisk uses unknown so
virt-xml-validate will fail to validate when unknown is found

Signed-off-by: John Ferlan jfer...@redhat.com
---
 docs/schemas/storagepool.rng | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng
index db6ff49..ea682a9 100644
--- a/docs/schemas/storagepool.rng
+++ b/docs/schemas/storagepool.rng
@@ -413,7 +413,7 @@
   element name='format'
 attribute name='type'
   choice
-valuenone/value
+valueunknown/value
 valuedos/value
 valuedvh/value
 valuegpt/value
-- 
2.1.0

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


[libvirt] [PATCH 0/2] Fix a couple issues found with disk backend

2015-06-08 Thread John Ferlan
Validation of https://bugzilla.redhat.com/show_bug.cgi?id=1181062 raised
a couple of questions about XML format and the defaults - these patches
address those questions.

John Ferlan (2):
  docs: Adjust Disk storage rng
  storage: Force setting of disk format type

 docs/schemas/storagepool.rng   | 2 +-
 src/storage/storage_backend_disk.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

-- 
2.1.0

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


[libvirt] [PATCH 2/2] storage: Force setting of disk format type

2015-06-08 Thread John Ferlan
Commit id '832a9256' adjusted the code to recognize when the default
type of unknown was provided as the format type and to use dos if
found. Since the pool is built with dos and it could cause some
confusion when formatting the XML after building by seeing unknown
in the output, let's just adjust the pool's setting to dos so that
subsequent formats will see the value.

Signed-off-by: John Ferlan jfer...@redhat.com
---
 src/storage/storage_backend_disk.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/storage/storage_backend_disk.c 
b/src/storage/storage_backend_disk.c
index c4bd6fe..b016c4f 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -472,8 +472,9 @@ virStorageBackendDiskBuildPool(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 /* eg parted /dev/sda mklabel --script msdos */
 int format = pool-def-source.format;
 const char *fmt;
-if (format == VIR_STORAGE_POOL_DISK_UNKNOWN ||
-format == VIR_STORAGE_POOL_DISK_DOS)
+if (format == VIR_STORAGE_POOL_DISK_UNKNOWN)
+format = pool-def-source.format = VIR_STORAGE_POOL_DISK_DOS;
+if (format == VIR_STORAGE_POOL_DISK_DOS)
 fmt = msdos;
 else
 fmt = virStoragePoolFormatDiskTypeToString(format);
-- 
2.1.0

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


Re: [libvirt] [PATCH 2/3] rpc: add API for checking IPv4/6 availability

2015-06-08 Thread Martin Kletzander

On Fri, Jun 05, 2015 at 09:47:44AM +0100, Daniel P. Berrange wrote:

The socket test suite has a function for checking if IPv4
or IPv6 are available, and returning a free socket. The
first bit of that will be needed in another test, so pull
that logic out into a separate helper method.

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
src/libvirt_remote.syms  |  1 +
src/rpc/virnetsocket.c   | 66 
src/rpc/virnetsocket.h   |  3 +++
tests/virnetsockettest.c | 36 ++
4 files changed, 72 insertions(+), 34 deletions(-)



ACK


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

[libvirt] [PATCH 2/2] cmdNetworkList: Introduce --name, --uuid, --table

2015-06-08 Thread Michal Privoznik
When reviewing some network patches, I've noticed we don't have
those switches to out 'net-list' command. We should. They are
merely copied over from 'list' command.

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
 tools/virsh-network.c | 69 ---
 tools/virsh.pod   |  7 ++
 2 files changed, 62 insertions(+), 14 deletions(-)

diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 182293e..66123c4 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -644,6 +644,18 @@ static const vshCmdOptDef opts_network_list[] = {
  .type = VSH_OT_BOOL,
  .help = N_(list networks with autostart disabled)
 },
+{.name = uuid,
+ .type = VSH_OT_BOOL,
+ .help = N_(list uuid's only)
+},
+{.name = name,
+ .type = VSH_OT_BOOL,
+ .help = N_(list network names only)
+},
+{.name = table,
+ .type = VSH_OT_BOOL,
+ .help = N_(list table (default))
+},
 {.name = NULL}
 };
 
@@ -655,6 +667,11 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd 
ATTRIBUTE_UNUSED)
 {
 vshNetworkListPtr list = NULL;
 size_t i;
+bool ret = false;
+bool optName = vshCommandOptBool(cmd, name);
+bool optTable = vshCommandOptBool(cmd, table);
+bool optUUID = vshCommandOptBool(cmd, uuid);
+char uuid[VIR_UUID_STRING_BUFLEN];
 unsigned int flags = VIR_CONNECT_LIST_NETWORKS_ACTIVE;
 
 if (vshCommandOptBool(cmd, inactive))
@@ -670,33 +687,57 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd 
ATTRIBUTE_UNUSED)
 FILTER(autostart, VIR_CONNECT_LIST_NETWORKS_AUTOSTART);
 FILTER(no-autostart, VIR_CONNECT_LIST_NETWORKS_NO_AUTOSTART);
 
+if (optTable + optName + optUUID  1) {
+vshError(ctl, %s,
+ _(Only one argument from --table, --name and --uuid 
+   may be specified.));
+return false;
+}
+
+if (!optUUID  !optName)
+optTable = true;
+
 if (!(list = vshNetworkListCollect(ctl, flags)))
 return false;
 
-vshPrintExtra(ctl,  %-20s %-10s %-13s %s\n, _(Name), _(State),
-  _(Autostart), _(Persistent));
-vshPrintExtra(ctl,
-  
--\n);
+if (optTable) {
+vshPrintExtra(ctl,  %-20s %-10s %-13s %s\n, _(Name), _(State),
+  _(Autostart), _(Persistent));
+vshPrintExtra(ctl,
+  
--\n);
+}
 
 for (i = 0; i  list-nnets; i++) {
 virNetworkPtr network = list-nets[i];
 const char *autostartStr;
 int is_autostart = 0;
 
-if (virNetworkGetAutostart(network, is_autostart)  0)
-autostartStr = _(no autostart);
-else
-autostartStr = is_autostart ? _(yes) : _(no);
+if (optTable) {
+if (virNetworkGetAutostart(network, is_autostart)  0)
+autostartStr = _(no autostart);
+else
+autostartStr = is_autostart ? _(yes) : _(no);
 
-vshPrint(ctl,  %-20s %-10s %-13s %s\n,
- virNetworkGetName(network),
- virNetworkIsActive(network) ? _(active) : _(inactive),
- autostartStr,
- virNetworkIsPersistent(network) ? _(yes) : _(no));
+vshPrint(ctl,  %-20s %-10s %-13s %s\n,
+ virNetworkGetName(network),
+ virNetworkIsActive(network) ? _(active) : _(inactive),
+ autostartStr,
+ virNetworkIsPersistent(network) ? _(yes) : _(no));
+} else if (optUUID) {
+if (virNetworkGetUUIDString(network, uuid)  0) {
+vshError(ctl, %s, _(Failed to get network's UUID));
+goto cleanup;
+}
+vshPrint(ctl, %s\n, uuid);
+} else if (optName) {
+vshPrint(ctl, %s\n, virNetworkGetName(network));
+}
 }
 
+ret = true;
+ cleanup:
 vshNetworkListFree(list);
-return true;
+return ret;
 }
 #undef FILTER
 
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 4e3f82a..9b57c8c 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -2834,6 +2834,7 @@ events until a timeout or interrupt key.
 Returns basic information about the Inetwork object.
 
 =item Bnet-list [I--inactive | I--all]
+  { [I--table] | I--name | I--uuid }
   [I--persistent] [--transient]
   [I--autostart] [--no-autostart]
 
@@ -2844,6 +2845,12 @@ by I--persistent to list the persistent ones, 
I--transient to list the
 transient ones, I--autostart to list the ones with autostart enabled, and
 I--no-autostart to list the ones with autostart disabled.
 
+If I--name is specified, network names are printed instead of the table
+formatted one per line. If I--uuid is specified network's UUID's are printed
+instead of names. Flag I--table specifies that the 

[libvirt] [PATCH] qemuBuildDriveStr: s/virBufferEscapeString/virBufferAsprintf/

2015-06-08 Thread Michal Privoznik
We are using it to print a value that can't be NULL and does not need
any escaping anyway.

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
 src/qemu/qemu_command.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 61faa57..b8cdd3c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3724,7 +3724,7 @@ qemuBuildDriveStr(virConnectPtr conn,
   disk-geometry.sectors);
 
 if (disk-geometry.trans != VIR_DOMAIN_DISK_TRANS_DEFAULT)
-virBufferEscapeString(opt, ,trans=%s, trans);
+virBufferAsprintf(opt, ,trans=%s, trans);
 }
 
 if (disk-serial 
-- 
2.3.6

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


Re: [libvirt] [PATCH 0/2] Fix network names with quotes

2015-06-08 Thread Michal Privoznik
On 01.06.2015 10:06, Shivaprasad G Bhat wrote:
 The following series implements...
 
 ---
 
 Shivaprasad G Bhat (2):
   fix domaincommon.rng to accept network name with quotes
   escape quotes for dsmasq conf contents
 
 
  docs/schemas/domaincommon.rng  |2 +-
  src/util/virdnsmasq.c  |   25 +++
  src/util/virpidfile.c  |   15 
  .../nat-network-name-with-quotes.conf  |   20 +++
  .../nat-network-name-with-quotes.xml   |   26 
 
  tests/networkxml2conftest.c|1 +
  6 files changed, 79 insertions(+), 10 deletions(-)
  create mode 100644 
 tests/networkxml2confdata/nat-network-name-with-quotes.conf
  create mode 100644 tests/networkxml2confdata/nat-network-name-with-quotes.xml
 


There's nothing wrong with the patches. I'm just curious, what's the use
case? I always thought that name should be something simple. On the
other hand, we do something similar with domain names IIRC.

Michal

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


[libvirt] [PATCH 1/2] cmdNetworkList: switch to FILTER

2015-06-08 Thread Michal Privoznik
Instead of sticking to old code pattern use the one laid out by
cmdList. Use FILTER() macro instead of series of boolean
variables.

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
 tools/virsh-network.c | 28 ++--
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 45f4840..182293e 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -647,37 +647,28 @@ static const vshCmdOptDef opts_network_list[] = {
 {.name = NULL}
 };
 
+#define FILTER(NAME, FLAG)  \
+if (vshCommandOptBool(cmd, NAME))   \
+flags |= (FLAG)
 static bool
 cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
 {
 vshNetworkListPtr list = NULL;
 size_t i;
-bool inactive = vshCommandOptBool(cmd, inactive);
-bool all = vshCommandOptBool(cmd, all);
-bool persistent = vshCommandOptBool(cmd, persistent);
-bool transient = vshCommandOptBool(cmd, transient);
-bool autostart = vshCommandOptBool(cmd, autostart);
-bool no_autostart = vshCommandOptBool(cmd, no-autostart);
 unsigned int flags = VIR_CONNECT_LIST_NETWORKS_ACTIVE;
 
-if (inactive)
+if (vshCommandOptBool(cmd, inactive))
 flags = VIR_CONNECT_LIST_NETWORKS_INACTIVE;
 
-if (all)
+if (vshCommandOptBool(cmd, all))
 flags = VIR_CONNECT_LIST_NETWORKS_ACTIVE |
 VIR_CONNECT_LIST_NETWORKS_INACTIVE;
 
-if (persistent)
- flags |= VIR_CONNECT_LIST_NETWORKS_PERSISTENT;
+FILTER(persistent, VIR_CONNECT_LIST_NETWORKS_PERSISTENT);
+FILTER(transient, VIR_CONNECT_LIST_NETWORKS_TRANSIENT);
 
-if (transient)
- flags |= VIR_CONNECT_LIST_NETWORKS_TRANSIENT;
-
-if (autostart)
- flags |= VIR_CONNECT_LIST_NETWORKS_AUTOSTART;
-
-if (no_autostart)
- flags |= VIR_CONNECT_LIST_NETWORKS_NO_AUTOSTART;
+FILTER(autostart, VIR_CONNECT_LIST_NETWORKS_AUTOSTART);
+FILTER(no-autostart, VIR_CONNECT_LIST_NETWORKS_NO_AUTOSTART);
 
 if (!(list = vshNetworkListCollect(ctl, flags)))
 return false;
@@ -707,6 +698,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd 
ATTRIBUTE_UNUSED)
 vshNetworkListFree(list);
 return true;
 }
+#undef FILTER
 
 /*
  * net-name command
-- 
2.3.6

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


[libvirt] [PATCH 0/2] Introduce new net-list switches

2015-06-08 Thread Michal Privoznik
I think they might be helpful.

Michal Privoznik (2):
  cmdNetworkList: switch to FILTER
  cmdNetworkList: Introduce --name, --uuid, --table

 tools/virsh-network.c | 93 ++-
 tools/virsh.pod   |  7 
 2 files changed, 70 insertions(+), 30 deletions(-)

-- 
2.3.6

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