[libvirt] [PATCH 0/3] Resolve a few coverity issues

2014-07-21 Thread Peter Krempa
Mostly introduced by the domtop program.

Peter Krempa (3):
  examples: domtop: Fix uninitialized variable use
  examples: domtop: Avoid leaking memory
  util: Check return value from virStrToLong* functions

 examples/domtop/domtop.c | 10 +++---
 src/util/virsexpr.c  |  6 +++---
 src/util/virstring.h | 30 --
 src/vbox/vbox_tmpl.c |  4 ++--
 src/xen/xs_internal.c|  2 +-
 src/xenxs/xen_xm.c   |  9 +++--
 6 files changed, 36 insertions(+), 25 deletions(-)

-- 
2.0.0

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


[libvirt] [PATCH 3/3] util: Check return value from virStrToLong* functions

2014-07-21 Thread Peter Krempa
We do so in the vast majority of places, so there's no problem of adding
the attribute to enforce it by the complier and fix a few leftover
places.

This was originally pointed out by Coverity as a recent change triggered
it's warning that our code checked the vast majority of returns from
virStrToLong_ui.
---
 src/util/virsexpr.c   |  6 +++---
 src/util/virstring.h  | 30 --
 src/vbox/vbox_tmpl.c  |  4 ++--
 src/xen/xs_internal.c |  2 +-
 src/xenxs/xen_xm.c|  9 +++--
 5 files changed, 33 insertions(+), 18 deletions(-)

diff --git a/src/util/virsexpr.c b/src/util/virsexpr.c
index f5eb364..f8a0ccd 100644
--- a/src/util/virsexpr.c
+++ b/src/util/virsexpr.c
@@ -567,7 +567,7 @@ sexpr_int(const struct sexpr *sexpr, const char *name)

 if (value) {
 int val = 0;
-virStrToLong_i(value, NULL, 0, val);
+ignore_value(virStrToLong_i(value, NULL, 0, val));
 return val;
 }
 return 0;
@@ -590,7 +590,7 @@ sexpr_float(const struct sexpr *sexpr, const char *name)

 if (value) {
 double val = 0;
-virStrToDouble(value, NULL, val);
+ignore_value(virStrToDouble(value, NULL, val));
 return val;
 }
 return 0;
@@ -613,7 +613,7 @@ sexpr_u64(const struct sexpr *sexpr, const char *name)

 if (value) {
 unsigned long long val = 0;
-virStrToLong_ull(value, NULL, 0, val);
+ignore_value(virStrToLong_ull(value, NULL, 0, val));
 return val;
 }
 return 0;
diff --git a/src/util/virstring.h b/src/util/virstring.h
index df25441..267fbd0 100644
--- a/src/util/virstring.h
+++ b/src/util/virstring.h
@@ -51,43 +51,53 @@ char *virArgvToString(const char *const *argv);
 int virStrToLong_i(char const *s,
char **end_ptr,
int base,
-   int *result);
+   int *result)
+ATTRIBUTE_RETURN_CHECK;

 int virStrToLong_ui(char const *s,
 char **end_ptr,
 int base,
-unsigned int *result);
+unsigned int *result)
+ATTRIBUTE_RETURN_CHECK;
 int virStrToLong_uip(char const *s,
  char **end_ptr,
  int base,
- unsigned int *result);
+ unsigned int *result)
+ATTRIBUTE_RETURN_CHECK;
 int virStrToLong_l(char const *s,
char **end_ptr,
int base,
-   long *result);
+   long *result)
+ATTRIBUTE_RETURN_CHECK;
 int virStrToLong_ul(char const *s,
 char **end_ptr,
 int base,
-unsigned long *result);
+unsigned long *result)
+ATTRIBUTE_RETURN_CHECK;
 int virStrToLong_ulp(char const *s,
  char **end_ptr,
  int base,
- unsigned long *result);
+ unsigned long *result)
+ATTRIBUTE_RETURN_CHECK;
 int virStrToLong_ll(char const *s,
 char **end_ptr,
 int base,
-long long *result);
+long long *result)
+ATTRIBUTE_RETURN_CHECK;
 int virStrToLong_ull(char const *s,
  char **end_ptr,
  int base,
- unsigned long long *result);
+ unsigned long long *result)
+ATTRIBUTE_RETURN_CHECK;
 int virStrToLong_ullp(char const *s,
   char **end_ptr,
   int base,
-  unsigned long long *result);
+  unsigned long long *result)
+ATTRIBUTE_RETURN_CHECK;
 int virStrToDouble(char const *s,
char **end_ptr,
-   double *result);
+   double *result)
+ATTRIBUTE_RETURN_CHECK;

 void virSkipSpaces(const char **str) ATTRIBUTE_NONNULL(1);
 void virSkipSpacesAndBackslash(const char **str) ATTRIBUTE_NONNULL(1);
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index e60a672..a18d7ab 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -2344,8 +2344,8 @@ static void vboxHostDeviceGetXMLDesc(vboxGlobalData 
*data, virDomainDefPtr def,
 VBOX_UTF16_TO_UTF8(vendorIdUtf16, vendorIdUtf8);
 VBOX_UTF16_TO_UTF8(productIdUtf16, productIdUtf8);

-virStrToLong_ui(vendorIdUtf8, endptr, 16, vendorId);
-virStrToLong_ui(productIdUtf8, endptr, 16, productId);
+ignore_value(virStrToLong_ui(vendorIdUtf8, endptr, 16, vendorId));
+ignore_value(virStrToLong_ui(productIdUtf8, endptr, 16, productId));

 def-hostdevs[USBFilterCount]-source.subsys.u.usb.vendor  = vendorId;
 def-hostdevs[USBFilterCount]-source.subsys.u.usb.product = productId;
diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c
index 8ddcd7e..7e2d477 100644
--- a/src/xen/xs_internal.c
+++ b/src/xen/xs_internal.c
@@ -335,7 +335,7 @@ 

[libvirt] [PATCH 1/3] examples: domtop: Fix uninitialized variable use

2014-07-21 Thread Peter Krempa
max_id could be used uninitialized in the cleanup section after the
domain wasn't found.

Discovered by Coverity.
---
 examples/domtop/domtop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/domtop/domtop.c b/examples/domtop/domtop.c
index 8118793..7661057 100644
--- a/examples/domtop/domtop.c
+++ b/examples/domtop/domtop.c
@@ -254,7 +254,7 @@ do_top(virConnectPtr conn,
 {
 int ret = -1;
 virDomainPtr dom;
-int max_id;
+int max_id = 0;
 int nparams = 0, then_nparams = 0, now_nparams = 0;
 virTypedParameterPtr then_params = NULL, now_params = NULL;
 struct sigaction action_stop;
-- 
2.0.0

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


[libvirt] [PATCH 2/3] examples: domtop: Avoid leaking memory

2014-07-21 Thread Peter Krempa
Use the virTypedParamsFree unconditionally as it handles NULL well and
has the benefit of freeing a typed parameter array even if it wasn't yet
assigned, but only allocated.
---
 examples/domtop/domtop.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/examples/domtop/domtop.c b/examples/domtop/domtop.c
index 7661057..4ac7889 100644
--- a/examples/domtop/domtop.c
+++ b/examples/domtop/domtop.c
@@ -334,12 +334,8 @@ do_top(virConnectPtr conn,

 ret = 0;
  cleanup:
-if (max_id  0) {
-if (now_nparams  0)
-virTypedParamsFree(now_params, now_nparams * max_id);
-if (then_nparams  0)
-virTypedParamsFree(then_params, then_nparams * max_id);
-}
+virTypedParamsFree(now_params, now_nparams * max_id);
+virTypedParamsFree(then_params, then_nparams * max_id);
 if (dom)
 virDomainFree(dom);
 return ret;
-- 
2.0.0

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


Re: [libvirt] [PATCH 3/7] qemu: snapshot: Convert if-else switch to switch statement

2014-07-21 Thread Peter Krempa
On 07/19/14 00:31, Eric Blake wrote:
 On 07/18/2014 10:11 AM, Peter Krempa wrote:
 Convert the target snapshot state selector to a switch statement
 enumerating all possible values. This points out a few mistakes in the
 original selector.

 The logic of the code is preserved until later patches.
 ---
  src/qemu/qemu_driver.c | 22 --
  1 file changed, 16 insertions(+), 6 deletions(-)

 
 ACK.
 

Pushed; Thanks.

Peter



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 4/7] qemu: snapshot: Reject revertion from clearly bad states

2014-07-21 Thread Peter Krempa
On 07/19/14 00:33, Eric Blake wrote:
 On 07/18/2014 10:11 AM, Peter Krempa wrote:
 Report errors on some states snapshots done by qemu should never reach
 ---
  src/qemu/qemu_driver.c | 12 +---
  1 file changed, 9 insertions(+), 3 deletions(-)

 
 +
 +case VIR_DOMAIN_NOSTATE:
 +case VIR_DOMAIN_BLOCKED:
 +case VIR_DOMAIN_LAST:
 +virReportError(VIR_ERR_INTERNAL_ERROR,
 +   _(Invalid target domain state '%s'. Refusing 
 + snapshot revertion ),
 
 s/revertion /reversion/
 
 (typo and trailing space)
 
 +   virDomainStateTypeToString(snap-def-state));
 +goto cleanup;
  }
 
 ACK with that fixed.  It might also be nice to patch
 qemuDomainSnapshotCreateXML with the _REDEFINE flag to likewise reject
 modifying an existing snapshot into one of these states.
 

Fixed  pushed;

Thanks.

Peter



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] LXC: show used memory as 0 when domain is not active

2014-07-21 Thread chenhanx...@cn.fujitsu.com
ping

 -Original Message-
 From: libvir-list-boun...@redhat.com [mailto:libvir-list-boun...@redhat.com]
 On Behalf Of Chen Hanxiao
 Sent: Thursday, July 17, 2014 5:28 PM
 To: libvir-list@redhat.com
 Subject: [libvirt] [PATCH] LXC: show used memory as 0 when domain is not 
 active
 
 Before:
 virsh # dominfo chx3
 State:  shut off
 Max memory: 92160 KiB
 Used memory:92160 KiB
 
 After:
 virsh # dominfo container1
 State:  shut off
 Max memory: 92160 KiB
 Used memory:0 KiB
 
 Similar to qemu cases.
 
 Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com
 ---
  src/lxc/lxc_driver.c   | 2 +-
  src/qemu/qemu_driver.c | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
 index b7b4b02..f094f86 100644
 --- a/src/lxc/lxc_driver.c
 +++ b/src/lxc/lxc_driver.c
 @@ -584,7 +584,7 @@ static int lxcDomainGetInfo(virDomainPtr dom,
 
  if (!virDomainObjIsActive(vm)) {
  info-cpuTime = 0;
 -info-memory = vm-def-mem.cur_balloon;
 +info-memory = 0;
  } else {
  if (virCgroupGetCpuacctUsage(priv-cgroup, (info-cpuTime))  0) {
  virReportError(VIR_ERR_OPERATION_FAILED,
 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index 33541d3..01107cf 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -2534,7 +2534,7 @@ static int qemuDomainGetInfo(virDomainPtr dom,
  info-memory = vm-def-mem.cur_balloon;
  }
  } else {
 -info-memory = vm-def-mem.cur_balloon;
 +info-memory = 0;
  }
 
  info-nrVirtCpu = vm-def-vcpus;
 --
 1.9.0
 
 --
 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 V2 1/3] rename arguments of virthread functions

2014-07-21 Thread Jincheng Miao
For keeping consistence of other functions in virthread.c,
rename arguments 'm', 'c' to 'mutex', 'rwlock' and 'cond'.

Signed-off-by: Jincheng Miao jm...@redhat.com
---
 src/util/virthread.c | 65 ++--
 src/util/virthread.h | 33 +-
 2 files changed, 50 insertions(+), 48 deletions(-)

diff --git a/src/util/virthread.c b/src/util/virthread.c
index 7e841d1..e22cadd 100644
--- a/src/util/virthread.c
+++ b/src/util/virthread.c
@@ -48,13 +48,13 @@ int virOnce(virOnceControlPtr once, virOnceFunc init)
 }
 
 
-int virMutexInit(virMutexPtr m)
+int virMutexInit(virMutexPtr mutex)
 {
 int ret;
 pthread_mutexattr_t attr;
 pthread_mutexattr_init(attr);
 pthread_mutexattr_settype(attr, PTHREAD_MUTEX_NORMAL);
-ret = pthread_mutex_init(m-lock, attr);
+ret = pthread_mutex_init(mutex-lock, attr);
 pthread_mutexattr_destroy(attr);
 if (ret != 0) {
 errno = ret;
@@ -63,13 +63,13 @@ int virMutexInit(virMutexPtr m)
 return 0;
 }
 
-int virMutexInitRecursive(virMutexPtr m)
+int virMutexInitRecursive(virMutexPtr mutex)
 {
 int ret;
 pthread_mutexattr_t attr;
 pthread_mutexattr_init(attr);
 pthread_mutexattr_settype(attr, PTHREAD_MUTEX_RECURSIVE);
-ret = pthread_mutex_init(m-lock, attr);
+ret = pthread_mutex_init(mutex-lock, attr);
 pthread_mutexattr_destroy(attr);
 if (ret != 0) {
 errno = ret;
@@ -78,26 +78,26 @@ int virMutexInitRecursive(virMutexPtr m)
 return 0;
 }
 
-void virMutexDestroy(virMutexPtr m)
+void virMutexDestroy(virMutexPtr mutex)
 {
-pthread_mutex_destroy(m-lock);
+pthread_mutex_destroy(mutex-lock);
 }
 
-void virMutexLock(virMutexPtr m)
+void virMutexLock(virMutexPtr mutex)
 {
-pthread_mutex_lock(m-lock);
+pthread_mutex_lock(mutex-lock);
 }
 
-void virMutexUnlock(virMutexPtr m)
+void virMutexUnlock(virMutexPtr mutex)
 {
-pthread_mutex_unlock(m-lock);
+pthread_mutex_unlock(mutex-lock);
 }
 
 
-int virRWLockInit(virRWLockPtr m)
+int virRWLockInit(virRWLockPtr rwlock)
 {
 int ret;
-ret = pthread_rwlock_init(m-lock, NULL);
+ret = pthread_rwlock_init(rwlock-lock, NULL);
 if (ret != 0) {
 errno = ret;
 return -1;
@@ -105,59 +105,60 @@ int virRWLockInit(virRWLockPtr m)
 return 0;
 }
 
-void virRWLockDestroy(virRWLockPtr m)
+void virRWLockDestroy(virRWLockPtr rwlock)
 {
-pthread_rwlock_destroy(m-lock);
+pthread_rwlock_destroy(rwlock-lock);
 }
 
 
-void virRWLockRead(virRWLockPtr m)
+void virRWLockRead(virRWLockPtr rwlock)
 {
-pthread_rwlock_rdlock(m-lock);
+pthread_rwlock_rdlock(rwlock-lock);
 }
 
-void virRWLockWrite(virRWLockPtr m)
+void virRWLockWrite(virRWLockPtr rwlock)
 {
-pthread_rwlock_wrlock(m-lock);
+pthread_rwlock_wrlock(rwlock-lock);
 }
 
 
-void virRWLockUnlock(virRWLockPtr m)
+void virRWLockUnlock(virRWLockPtr rwlock)
 {
-pthread_rwlock_unlock(m-lock);
+pthread_rwlock_unlock(rwlock-lock);
 }
 
-int virCondInit(virCondPtr c)
+int virCondInit(virCondPtr cond)
 {
 int ret;
-if ((ret = pthread_cond_init(c-cond, NULL)) != 0) {
+if ((ret = pthread_cond_init(cond-cond, NULL)) != 0) {
 errno = ret;
 return -1;
 }
 return 0;
 }
 
-int virCondDestroy(virCondPtr c)
+int virCondDestroy(virCondPtr cond)
 {
 int ret;
-if ((ret = pthread_cond_destroy(c-cond)) != 0) {
+if ((ret = pthread_cond_destroy(cond-cond)) != 0) {
 errno = ret;
 return -1;
 }
 return 0;
 }
 
-int virCondWait(virCondPtr c, virMutexPtr m)
+int virCondWait(virCondPtr cond, virMutexPtr mutex)
 {
 int ret;
-if ((ret = pthread_cond_wait(c-cond, m-lock)) != 0) {
+if ((ret = pthread_cond_wait(cond-cond, mutex-lock)) != 0) {
 errno = ret;
 return -1;
 }
 return 0;
 }
 
-int virCondWaitUntil(virCondPtr c, virMutexPtr m, unsigned long long whenms)
+int virCondWaitUntil(virCondPtr cond, virMutexPtr mutex,
+ unsigned long long whenms)
 {
 int ret;
 struct timespec ts;
@@ -165,21 +166,21 @@ int virCondWaitUntil(virCondPtr c, virMutexPtr m, 
unsigned long long whenms)
 ts.tv_sec = whenms / 1000;
 ts.tv_nsec = (whenms % 1000) * 1000;
 
-if ((ret = pthread_cond_timedwait(c-cond, m-lock, ts)) != 0) {
+if ((ret = pthread_cond_timedwait(cond-cond, mutex-lock, ts)) != 0) {
 errno = ret;
 return -1;
 }
 return 0;
 }
 
-void virCondSignal(virCondPtr c)
+void virCondSignal(virCondPtr cond)
 {
-pthread_cond_signal(c-cond);
+pthread_cond_signal(cond-cond);
 }
 
-void virCondBroadcast(virCondPtr c)
+void virCondBroadcast(virCondPtr cond)
 {
-pthread_cond_broadcast(c-cond);
+pthread_cond_broadcast(cond-cond);
 }
 
 struct virThreadArgs {
diff --git a/src/util/virthread.h b/src/util/virthread.h
index 4b92a43..7c71c6b 100644
--- a/src/util/virthread.h
+++ b/src/util/virthread.h
@@ -122,35 +122,36 @@ unsigned long long virThreadID(virThreadPtr 

[libvirt] [PATCH V2 3/3] remove error message after virMutexInit virRWLockInit virCondInit

2014-07-21 Thread Jincheng Miao
Signed-off-by: Jincheng Miao jm...@redhat.com
---
 daemon/remote.c |  1 -
 src/conf/interface_conf.c   |  2 --
 src/conf/network_conf.c |  2 --
 src/conf/node_device_conf.c |  2 --
 src/conf/nwfilter_conf.c|  2 --
 src/conf/object_event.c |  2 --
 src/conf/storage_conf.c |  2 --
 src/conf/virchrdev.c|  2 --
 src/esx/esx_vi.c| 15 +++
 src/fdstream.c  |  2 --
 src/libxl/libxl_driver.c|  2 --
 src/locking/lock_daemon.c   |  5 -
 src/node_device/node_device_udev.c  |  1 -
 src/nwfilter/nwfilter_learnipaddr.c |  2 --
 src/parallels/parallels_driver.c|  5 +
 src/qemu/qemu_agent.c   |  2 --
 src/qemu/qemu_capabilities.c|  2 --
 src/qemu/qemu_driver.c  |  1 -
 src/qemu/qemu_monitor.c |  6 ++
 src/remote/remote_driver.c  |  2 --
 src/rpc/virnetclient.c  |  5 +
 src/test/test_driver.c  |  4 
 src/util/vireventpoll.c |  5 +
 src/util/virlockspace.c |  4 
 src/util/virobject.c|  2 --
 src/xen/xen_driver.c|  2 --
 tests/qemumonitortestutils.c|  2 --
 27 files changed, 8 insertions(+), 76 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index ea16789..d3cf8a8 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -1164,7 +1164,6 @@ void *remoteClientInitHook(virNetServerClientPtr client,
 
 if (virMutexInit(priv-lock)  0) {
 VIR_FREE(priv);
-virReportSystemError(errno, %s, _(unable to init mutex));
 return NULL;
 }
 
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index 103e878..87dc79e 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -1250,8 +1250,6 @@ virInterfaceObjPtr 
virInterfaceAssignDef(virInterfaceObjListPtr interfaces,
 if (VIR_ALLOC(iface)  0)
 return NULL;
 if (virMutexInit(iface-lock)  0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   %s, _(cannot initialize mutex));
 VIR_FREE(iface);
 return NULL;
 }
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index ce4d4d8..574727a 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -388,8 +388,6 @@ virNetworkAssignDef(virNetworkObjListPtr nets,
 if (VIR_ALLOC(network)  0)
 return NULL;
 if (virMutexInit(network-lock)  0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   %s, _(cannot initialize mutex));
 VIR_FREE(network);
 return NULL;
 }
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 30aa477..ed4cd2a 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -183,8 +183,6 @@ virNodeDeviceObjPtr 
virNodeDeviceAssignDef(virNodeDeviceObjListPtr devs,
 return NULL;
 
 if (virMutexInit(device-lock)  0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   %s, _(cannot initialize mutex));
 VIR_FREE(device);
 return NULL;
 }
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index 52f24e4..b662e02 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -3104,8 +3104,6 @@ virNWFilterObjAssignDef(virNWFilterObjListPtr nwfilters,
 return NULL;
 
 if (virMutexInitRecursive(nwfilter-lock)  0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   %s, _(cannot initialize mutex));
 VIR_FREE(nwfilter);
 return NULL;
 }
diff --git a/src/conf/object_event.c b/src/conf/object_event.c
index beef3e1..86d0eb8 100644
--- a/src/conf/object_event.c
+++ b/src/conf/object_event.c
@@ -577,8 +577,6 @@ virObjectEventStateNew(void)
 goto error;
 
 if (virMutexInit(state-lock)  0) {
-virReportSystemError(errno, %s,
- _(unable to initialize state mutex));
 VIR_FREE(state);
 goto error;
 }
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 69333f5..1e8edff 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1694,8 +1694,6 @@ virStoragePoolObjAssignDef(virStoragePoolObjListPtr pools,
 return NULL;
 
 if (virMutexInit(pool-lock)  0) {
-virReportError(VIR_ERR_INTERNAL_ERROR, %s,
-   _(cannot initialize mutex));
 VIR_FREE(pool);
 return NULL;
 }
diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c
index 022fe71..a659b62 100644
--- a/src/conf/virchrdev.c
+++ b/src/conf/virchrdev.c
@@ -272,8 +272,6 @@ virChrdevsPtr virChrdevAlloc(void)
 return NULL;
 
 if (virMutexInit(devs-lock)  0) {
-virReportSystemError(errno, %s,
- _(Unable to init device stream mutex));
 VIR_FREE(devs);
 return NULL;
 }
diff --git 

[libvirt] [PATCH V2 2/3] add error report for virMutexInit virRWLockInit and virCondInit

2014-07-21 Thread Jincheng Miao
Implement vir{Mutex,RWLock,Cond}InitInternal functions which have
related error report when failure, and vir{Mutex,RWLock,Cond}Init
as macros. So that the caller no longer to print error message
explicitly.

Signed-off-by: Jincheng Miao jm...@redhat.com
---
 src/libvirt_private.syms |  7 +++---
 src/util/virthread.c | 56 +---
 src/util/virthread.h | 25 +
 3 files changed, 49 insertions(+), 39 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 8d3671c..b1c05d3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2015,18 +2015,17 @@ virSystemdTerminateMachine;
 # util/virthread.h
 virCondBroadcast;
 virCondDestroy;
-virCondInit;
+virCondInitInternal;
 virCondSignal;
 virCondWait;
 virCondWaitUntil;
 virMutexDestroy;
-virMutexInit;
-virMutexInitRecursive;
+virMutexInitInternal;
 virMutexLock;
 virMutexUnlock;
 virOnce;
 virRWLockDestroy;
-virRWLockInit;
+virRWLockInitInternal;
 virRWLockRead;
 virRWLockUnlock;
 virRWLockWrite;
diff --git a/src/util/virthread.c b/src/util/virthread.c
index e22cadd..36044eb 100644
--- a/src/util/virthread.c
+++ b/src/util/virthread.c
@@ -31,6 +31,13 @@
 
 #include viralloc.h
 
+#define VIR_THREAD_ERR_EXIT(str) do {   \
+errno = ret;\
+virReportSystemErrorFull(VIR_FROM_NONE, errno,  \
+ filename, funcname, linenr,\
+ %s, _(str)); \
+return -1;  \
+} while (0)
 
 /* Nothing special required for pthreads */
 int virThreadInitialize(void)
@@ -48,33 +55,20 @@ int virOnce(virOnceControlPtr once, virOnceFunc init)
 }
 
 
-int virMutexInit(virMutexPtr mutex)
+int virMutexInitInternal(virMutexPtr mutex, bool recursive,
+ const char *filename, const char *funcname,
+ size_t linenr)
 {
 int ret;
 pthread_mutexattr_t attr;
+int type = recursive ? PTHREAD_MUTEX_RECURSIVE : PTHREAD_MUTEX_NORMAL;
 pthread_mutexattr_init(attr);
-pthread_mutexattr_settype(attr, PTHREAD_MUTEX_NORMAL);
+pthread_mutexattr_settype(attr, type);
 ret = pthread_mutex_init(mutex-lock, attr);
 pthread_mutexattr_destroy(attr);
-if (ret != 0) {
-errno = ret;
-return -1;
-}
-return 0;
-}
+if (ret != 0)
+VIR_THREAD_ERR_EXIT(unable to init Mutex);
 
-int virMutexInitRecursive(virMutexPtr mutex)
-{
-int ret;
-pthread_mutexattr_t attr;
-pthread_mutexattr_init(attr);
-pthread_mutexattr_settype(attr, PTHREAD_MUTEX_RECURSIVE);
-ret = pthread_mutex_init(mutex-lock, attr);
-pthread_mutexattr_destroy(attr);
-if (ret != 0) {
-errno = ret;
-return -1;
-}
 return 0;
 }
 
@@ -94,14 +88,14 @@ void virMutexUnlock(virMutexPtr mutex)
 }
 
 
-int virRWLockInit(virRWLockPtr rwlock)
+int virRWLockInitInternal(virRWLockPtr rwlock, const char *filename,
+  const char *funcname, size_t linenr)
 {
 int ret;
 ret = pthread_rwlock_init(rwlock-lock, NULL);
-if (ret != 0) {
-errno = ret;
-return -1;
-}
+if (ret != 0)
+VIR_THREAD_ERR_EXIT(unable to init RWLock);
+
 return 0;
 }
 
@@ -127,13 +121,13 @@ void virRWLockUnlock(virRWLockPtr rwlock)
 pthread_rwlock_unlock(rwlock-lock);
 }
 
-int virCondInit(virCondPtr cond)
+int virCondInitInternal(virCondPtr cond, const char *filename,
+const char *funcname, size_t linenr)
 {
-int ret;
-if ((ret = pthread_cond_init(cond-cond, NULL)) != 0) {
-errno = ret;
-return -1;
-}
+int ret = pthread_cond_init(cond-cond, NULL);
+if (ret != 0)
+VIR_THREAD_ERR_EXIT(unable to init Condition);
+
 return 0;
 }
 
diff --git a/src/util/virthread.h b/src/util/virthread.h
index 7c71c6b..280294b 100644
--- a/src/util/virthread.h
+++ b/src/util/virthread.h
@@ -122,15 +122,27 @@ unsigned long long virThreadID(virThreadPtr thread);
 int virOnce(virOnceControlPtr once, virOnceFunc init)
 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
 
-int virMutexInit(virMutexPtr mutex) ATTRIBUTE_RETURN_CHECK;
-int virMutexInitRecursive(virMutexPtr mutex) ATTRIBUTE_RETURN_CHECK;
+int virMutexInitInternal(virMutexPtr mutex, bool recursive,
+ const char *filename, const char *funcname,
+ size_t linenr)
+ATTRIBUTE_RETURN_CHECK;
+# define virMutexInit(mutex)\
+virMutexInitInternal(mutex, false, __FILE__, __FUNCTION__, __LINE__)
+# define virMutexInitRecursive(mutex)   \
+virMutexInitInternal(mutex, true, __FILE__, __FUNCTION__, __LINE__)
+
 void virMutexDestroy(virMutexPtr mutex);
 
 

[libvirt] [PATCH V2 0/3] refactor virMutexInit virRWLockInit and virCondInit

2014-07-21 Thread Jincheng Miao

This patchset refactors vir{Mutex,RWLock,Cond}Init by calling a Initernal 
function,
which has the error reporting. So that the caller no longer to write a redundant
error message after them.

V2:
  removed quiet argument of vir{Mutex,RWLock,Cond}Internal.
  separated argument renaming patch.

Jincheng Miao (3):
  rename arguments of virthread functions
  add error report for virMutexInit virRWLockInit and virCondInit
  remove error message after virMutexInit virRWLockInit virCondInit

 daemon/remote.c |   1 -
 src/conf/interface_conf.c   |   2 -
 src/conf/network_conf.c |   2 -
 src/conf/node_device_conf.c |   2 -
 src/conf/nwfilter_conf.c|   2 -
 src/conf/object_event.c |   2 -
 src/conf/storage_conf.c |   2 -
 src/conf/virchrdev.c|   2 -
 src/esx/esx_vi.c|  15 +
 src/fdstream.c  |   2 -
 src/libvirt_private.syms|   7 +--
 src/libxl/libxl_driver.c|   2 -
 src/locking/lock_daemon.c   |   5 --
 src/node_device/node_device_udev.c  |   1 -
 src/nwfilter/nwfilter_learnipaddr.c |   2 -
 src/parallels/parallels_driver.c|   5 +-
 src/qemu/qemu_agent.c   |   2 -
 src/qemu/qemu_capabilities.c|   2 -
 src/qemu/qemu_driver.c  |   1 -
 src/qemu/qemu_monitor.c |   6 +-
 src/remote/remote_driver.c  |   2 -
 src/rpc/virnetclient.c  |   5 +-
 src/test/test_driver.c  |   4 --
 src/util/vireventpoll.c |   5 +-
 src/util/virlockspace.c |   4 --
 src/util/virobject.c|   2 -
 src/util/virthread.c| 109 +---
 src/util/virthread.h|  50 +++--
 src/xen/xen_driver.c|   2 -
 tests/qemumonitortestutils.c|   2 -
 30 files changed, 97 insertions(+), 153 deletions(-)

-- 
1.8.3.1

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


Re: [libvirt] [PATCH V2 2/3] add error report for virMutexInit virRWLockInit and virCondInit

2014-07-21 Thread Daniel P. Berrange
On Mon, Jul 21, 2014 at 06:13:36PM +0800, Jincheng Miao wrote:
 Implement vir{Mutex,RWLock,Cond}InitInternal functions which have
 related error report when failure, and vir{Mutex,RWLock,Cond}Init
 as macros. So that the caller no longer to print error message
 explicitly.
 
 Signed-off-by: Jincheng Miao jm...@redhat.com
 ---
  src/libvirt_private.syms |  7 +++---
  src/util/virthread.c | 56 
 +---
  src/util/virthread.h | 25 +
  3 files changed, 49 insertions(+), 39 deletions(-)
 

 +#define VIR_THREAD_ERR_EXIT(str) do {   \
 +errno = ret;\
 +virReportSystemErrorFull(VIR_FROM_NONE, errno,  \
 + filename, funcname, linenr,\
 + %s, _(str)); \
 +return -1;  \
 +} while (0)

Using '_(...)' here isn't going to work for translations because
xgettext won't find the strings.

 -}
 +if (ret != 0)
 +VIR_THREAD_ERR_EXIT(unable to init Mutex);


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

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


Re: [libvirt] [PATCH V2 2/3] add error report for virMutexInit virRWLockInit and virCondInit

2014-07-21 Thread Daniel P. Berrange
On Mon, Jul 21, 2014 at 06:13:36PM +0800, Jincheng Miao wrote:
 Implement vir{Mutex,RWLock,Cond}InitInternal functions which have
 related error report when failure, and vir{Mutex,RWLock,Cond}Init
 as macros. So that the caller no longer to print error message
 explicitly.
 
 Signed-off-by: Jincheng Miao jm...@redhat.com
 ---
  src/libvirt_private.syms |  7 +++---
  src/util/virthread.c | 56 
 +---
  src/util/virthread.h | 25 +
  3 files changed, 49 insertions(+), 39 deletions(-)
 

  
 +#define VIR_THREAD_ERR_EXIT(str) do {   \
 +errno = ret;\
 +virReportSystemErrorFull(VIR_FROM_NONE, errno,  \
 + filename, funcname, linenr,\
 + %s, _(str)); \
 +return -1;  \
 +} while (0)

[snip]

 -int virCondInit(virCondPtr cond)
 +int virCondInitInternal(virCondPtr cond, const char *filename,
 +const char *funcname, size_t linenr)
  {
 -int ret;
 -if ((ret = pthread_cond_init(cond-cond, NULL)) != 0) {
 -errno = ret;
 -return -1;
 -}
 +int ret = pthread_cond_init(cond-cond, NULL);
 +if (ret != 0)
 +VIR_THREAD_ERR_EXIT(unable to init Condition);
 +
  return 0;
  }

[snip]

 -int virCondInit(virCondPtr cond) ATTRIBUTE_RETURN_CHECK;
 +int virCondInitInternal(virCondPtr cond, const char *filename,
 +const char *funcname, size_t linenr)
 +ATTRIBUTE_RETURN_CHECK;
 +# define virCondInit(cond)  \
 +virCondInitInternal(cond, __FILE__, __FUNCTION__, __LINE__)
 +

I can see what you're trying todo here by passing in __FILE__,
__FUNCTION__, __LINE__ through from the calling site, but I don't
really think this is beneficial and is not the way we deal with
error reporting in any other similar helper APIs. IMHO just
remove all this passing around of source location and let it do
the default thing. In fact the default behaviour is probably
better since if we want to search for any thread related error
messages, we can query the journald for the virthread.c file
directly.

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] ipv6 slirp network

2014-07-21 Thread Vasiliy Tolstov
Hello. I have now slirp qemu network with ipv4 address, but for tests
i need also ipv6 addresses in slirp network. How can i provide this
args for qemu via libvirt or (best) via qemu args?
I found some commits about ipv6 slirp network but can't find args
needed to enable it.

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

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


Re: [libvirt] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Vasiliy Tolstov
2014-07-21 15:41 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
 ? The support was submitted to the list, but not commited.
 You can find the patches on
 http://lists.gnu.org/archive/html/qemu-devel/2014-03/msg05731.html
 and later.
 Unfortunately, nobody has yet found the time to review them.
 Documentation is added by patch 18, you can choose the prefix being
 exposed to userland just like with ipv4.


In case of ipv4 i have some default settings like network, dns and so.
In case of ipv6 does i have some default?

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

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


Re: [libvirt] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Vasiliy Tolstov
2014-07-21 15:49 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
 Yes, see the added documentation:

 +@item ip6-net=@var{addr}[/@var{int}]
 +Set IPv6 network address the guest will see. Optionally specify the prefix
 +size, as number of valid top-most bits. Default is fec0::/64.
 +
 +@item ip6-host=@var{addr}
 +Specify the guest-visible IPv6 address of the host. Default is the 2nd IPv6 
 in
 +the guest network, i.e. ::2.

 +@item ip6-dns=@var{addr}
 +Specify the guest-visible address of the IPv6 virtual nameserver. The address
 +must be different from the host address. Default is the 3rd IP in the guest
 +network, i.e. ::3.

 Most probably you'll want to set ip6-net to something else than
 fec0::/64 since OSes usually prefer IPv4 over fec0::/64.


Big thanks! I'm try apply patches and check.

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

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


Re: [libvirt] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Vasiliy Tolstov
Does it possible to get this patches via git branch or by another way?
As i see i can't get it via email because of html contents =(

2014-07-21 15:55 GMT+04:00 Vasiliy Tolstov v.tols...@selfip.ru:
 2014-07-21 15:49 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
 Yes, see the added documentation:

 +@item ip6-net=@var{addr}[/@var{int}]
 +Set IPv6 network address the guest will see. Optionally specify the prefix
 +size, as number of valid top-most bits. Default is fec0::/64.
 +
 +@item ip6-host=@var{addr}
 +Specify the guest-visible IPv6 address of the host. Default is the 2nd IPv6 
 in
 +the guest network, i.e. ::2.

 +@item ip6-dns=@var{addr}
 +Specify the guest-visible address of the IPv6 virtual nameserver. The 
 address
 +must be different from the host address. Default is the 3rd IP in the guest
 +network, i.e. ::3.

 Most probably you'll want to set ip6-net to something else than
 fec0::/64 since OSes usually prefer IPv4 over fec0::/64.


 Big thanks! I'm try apply patches and check.

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



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

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


Re: [libvirt] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Vasiliy Tolstov
2014-07-21 16:06 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
 I have pushed it to http://dept-info.labri.fr/~thibault/qemu-ipv6 , in
 the tosubmit branch.


Thanks!

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

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


Re: [libvirt] [PATCH 0/3] Resolve a few coverity issues

2014-07-21 Thread Pavel Hrdina
On 21.7.2014 10:51, Peter Krempa wrote:
 Mostly introduced by the domtop program.
 
 Peter Krempa (3):
   examples: domtop: Fix uninitialized variable use
   examples: domtop: Avoid leaking memory
   util: Check return value from virStrToLong* functions
 
  examples/domtop/domtop.c | 10 +++---
  src/util/virsexpr.c  |  6 +++---
  src/util/virstring.h | 30 --
  src/vbox/vbox_tmpl.c |  4 ++--
  src/xen/xs_internal.c|  2 +-
  src/xenxs/xen_xm.c   |  9 +++--
  6 files changed, 36 insertions(+), 25 deletions(-)
 

ACK series, I've also tested and it fixes all coverity issues.

Pavel

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


[libvirt] KVM Reset Password

2014-07-21 Thread Farzad Zarasvand
Hi,
I am using KVM with libvirt and openstack.
I try to reset an instance password. but I received error 501 not implemented. 
how do I change instance password?
thnx
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Samuel Thibault
Vasiliy Tolstov, le Mon 21 Jul 2014 15:42:54 +0400, a écrit :
 2014-07-21 15:41 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
  ? The support was submitted to the list, but not commited.
  You can find the patches on
  http://lists.gnu.org/archive/html/qemu-devel/2014-03/msg05731.html
  and later.
  Unfortunately, nobody has yet found the time to review them.
  Documentation is added by patch 18, you can choose the prefix being
  exposed to userland just like with ipv4.
 
 In case of ipv4 i have some default settings like network, dns and so.
 In case of ipv6 does i have some default?

Yes, see the added documentation:

+@item ip6-net=@var{addr}[/@var{int}]
+Set IPv6 network address the guest will see. Optionally specify the prefix
+size, as number of valid top-most bits. Default is fec0::/64.
+ 
+@item ip6-host=@var{addr}
+Specify the guest-visible IPv6 address of the host. Default is the 2nd IPv6 in
+the guest network, i.e. ::2.

+@item ip6-dns=@var{addr}
+Specify the guest-visible address of the IPv6 virtual nameserver. The address
+must be different from the host address. Default is the 3rd IP in the guest
+network, i.e. ::3.

Most probably you'll want to set ip6-net to something else than
fec0::/64 since OSes usually prefer IPv4 over fec0::/64.

Samuel

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


Re: [libvirt] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Samuel Thibault
Vasiliy Tolstov, le Mon 21 Jul 2014 15:59:53 +0400, a écrit :
 Does it possible to get this patches via git branch or by another way?
 As i see i can't get it via email because of html contents =(

I have pushed it to http://dept-info.labri.fr/~thibault/qemu-ipv6 , in
the tosubmit branch.

Samuel

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


Re: [libvirt] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Samuel Thibault
Hello,

Vasiliy Tolstov, le Mon 21 Jul 2014 15:34:16 +0400, a écrit :
 Hello. I have now slirp qemu network with ipv4 address, but for tests
 i need also ipv6 addresses in slirp network. How can i provide this
 args for qemu via libvirt or (best) via qemu args?
 I found some commits about ipv6 slirp network but can't find args
 needed to enable it.

? The support was submitted to the list, but not commited.
You can find the patches on
http://lists.gnu.org/archive/html/qemu-devel/2014-03/msg05731.html
and later.
Unfortunately, nobody has yet found the time to review them.
Documentation is added by patch 18, you can choose the prefix being
exposed to userland just like with ipv4.

Samuel

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


Re: [libvirt] [PATCH 0/3] Resolve a few coverity issues

2014-07-21 Thread Peter Krempa
On 07/21/14 15:04, Pavel Hrdina wrote:
 On 21.7.2014 10:51, Peter Krempa wrote:
 Mostly introduced by the domtop program.

 Peter Krempa (3):
   examples: domtop: Fix uninitialized variable use
   examples: domtop: Avoid leaking memory
   util: Check return value from virStrToLong* functions

  examples/domtop/domtop.c | 10 +++---
  src/util/virsexpr.c  |  6 +++---
  src/util/virstring.h | 30 --
  src/vbox/vbox_tmpl.c |  4 ++--
  src/xen/xs_internal.c|  2 +-
  src/xenxs/xen_xm.c   |  9 +++--
  6 files changed, 36 insertions(+), 25 deletions(-)

 
 ACK series, I've also tested and it fixes all coverity issues.
 
 Pavel

Pushed; Thanks.

Peter




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

[libvirt] [PATCHv2 1/2] qemu: snapshot: Forbid taking snapshot in invalid state

2014-07-21 Thread Peter Krempa
Similarly to 49a3a649a85f9d3d478be355aa8694bce889586a forbid creating
snapshots in domain states impossible to reach in qemu.
---
 src/qemu/qemu_driver.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1782913..91baa7d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13393,6 +13393,26 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
 goto cleanup;
 }

+/* allow snapshots only in certain states */
+switch ((virDomainState) vm-state.state) {
+/* valid states */
+case VIR_DOMAIN_RUNNING:
+case VIR_DOMAIN_PAUSED:
+case VIR_DOMAIN_SHUTDOWN:
+case VIR_DOMAIN_SHUTOFF:
+case VIR_DOMAIN_CRASHED:
+case VIR_DOMAIN_PMSUSPENDED:
+break;
+
+/* invalid states */
+case VIR_DOMAIN_NOSTATE:
+case VIR_DOMAIN_BLOCKED: /* invalid state, unused in qemu */
+case VIR_DOMAIN_LAST:
+virReportError(VIR_ERR_INTERNAL_ERROR, _(Invalid domain state %s),
+   virDomainStateTypeToString(vm-state.state));
+goto cleanup;
+}
+
 if (redefine) {
 if (!virDomainSnapshotRedefinePrep(domain, vm, def, snap,
update_current, flags)  0)
-- 
2.0.0

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


[libvirt] [PATCHv2 0/2] Deal with snapshots in PMSUSPENDED state

2014-07-21 Thread Peter Krempa
Peter Krempa (2):
  qemu: snapshot: Forbid taking snapshot in invalid state
  qemu: snapshot: Forbid taking/reverting snapshots in PMSUSPENDED state

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

-- 
2.0.0

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


[libvirt] [PATCHv2 2/2] qemu: snapshot: Forbid taking/reverting snapshots in PMSUSPENDED state

2014-07-21 Thread Peter Krempa
Qemu doesn't currently support them and behaves strangely. Just forbid
them.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1079162
---
 src/qemu/qemu_driver.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 91baa7d..eae23d3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13401,9 +13401,14 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
 case VIR_DOMAIN_SHUTDOWN:
 case VIR_DOMAIN_SHUTOFF:
 case VIR_DOMAIN_CRASHED:
-case VIR_DOMAIN_PMSUSPENDED:
 break;

+case VIR_DOMAIN_PMSUSPENDED:
+virReportError(VIR_ERR_OPERATION_UNSUPPORTED, %s,
+   _(qemu doesn't support taking snapshots of 
+ PMSUSPENDED guests));
+goto cleanup;
+
 /* invalid states */
 case VIR_DOMAIN_NOSTATE:
 case VIR_DOMAIN_BLOCKED: /* invalid state, unused in qemu */
@@ -14178,8 +14183,6 @@ static int 
qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
 case VIR_DOMAIN_SHUTDOWN:
 case VIR_DOMAIN_SHUTOFF:
 case VIR_DOMAIN_CRASHED:
-/* XXX: The following one is clearly wrong! */
-case VIR_DOMAIN_PMSUSPENDED:
 /* Transitions 1, 4, 7 */
 /* Newer qemu -loadvm refuses to revert to the state of a snapshot
  * created by qemu-img snapshot -c.  If the domain is running, we
@@ -14245,6 +14248,12 @@ static int 
qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
 }
 break;

+case VIR_DOMAIN_PMSUSPENDED:
+virReportError(VIR_ERR_OPERATION_UNSUPPORTED, %s,
+   _(qemu doesn't support reversion of snapshot taken in 
+ PMSUSPENDED state));
+goto cleanup;
+
 case VIR_DOMAIN_NOSTATE:
 case VIR_DOMAIN_BLOCKED:
 case VIR_DOMAIN_LAST:
-- 
2.0.0

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


Re: [libvirt] [PATCH 7/7] qemu: snapshot: Correctly revert snapshots in PMSUSPENDED state

2014-07-21 Thread Peter Krempa
On 07/19/14 01:12, Eric Blake wrote:
 On 07/18/2014 10:11 AM, Peter Krempa wrote:
 PMSUSPENDED state implies the qemu process running, so we should treat
 it that way. This increases the possible state space of transitions that
 may happen during the snapshot revert so this patch documents them as
 well.

 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1079162
 ---
  src/qemu/qemu_driver.c | 67 
 --
  1 file changed, 48 insertions(+), 19 deletions(-)
 
 I think this needs some rework - current qemu treats it as reverting to
 a pm wakeup event, and the guest will start running again (unless the
 user requested to revert as paused).
 

 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index 1f98f4a..f93e0fd 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -14052,22 +14052,29 @@ static int 
 qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
  virDomainDefPtr config = NULL;
  virQEMUDriverConfigPtr cfg = NULL;
  virCapsPtr caps = NULL;
 -int oldState = vm-state.state;
 +int oldState;

  virCheckFlags(VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING |
VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED |
VIR_DOMAIN_SNAPSHOT_REVERT_FORCE, -1);

  /* We have the following transitions, which create the following events:
 - * 1. inactive - inactive: none
 - * 2. inactive - running:  EVENT_STARTED
 - * 3. inactive - paused:   EVENT_STARTED, EVENT_PAUSED
 - * 4. running  - inactive: EVENT_STOPPED
 - * 5. running  - running:  none
 - * 6. running  - paused:   EVENT_PAUSED
 - * 7. paused   - inactive: EVENT_STOPPED
 - * 8. paused   - running:  EVENT_RESUMED
 - * 9. paused   - paused:   none
 + * 1.  inactive- inactive:none
 + * 2.  inactive- running: EVENT_STARTED
 + * 3.  inactive- paused:  EVENT_STARTED, EVENT_PAUSED
 + * 4.  running - inactive:EVENT_STOPPED
 + * 5.  running - running: none
 + * 6.  running - paused:  EVENT_PAUSED
 + * 7.  paused  - inactive:EVENT_STOPPED
 + * 8.  paused  - running: EVENT_RESUMED
 + * 9.  paused  - paused:  none
 + * 10. pmsuspended - pmsuspended: none
 
 this state is not possible with current qemu
 
 + * 11. pmsuspended - inactive:EVENT_STOPPED
 + * 12. pmsuspended - running: EVENT_RESUMED
 + * 13. pmsuspended - paused:  EVENT_PAUSED
 + * 14. inactive- pmsuspended: EVENT_STARTED, EVENT_PMSUSPENDED
 + * 15. paused  - pmsuspended: EVENT_PMSUSPENDED
 + * 16. running - pmsuspended: EVENT_PMSUSPENDED
 
 and these three states are not possible
 
   * Also, several transitions occur even if we fail partway through,
   * and use of FORCE can cause multiple transitions.
   */
 @@ -14075,6 +14082,8 @@ static int 
 qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
  if (!(vm = qemuDomObjFromSnapshot(snapshot)))
  return -1;

 +oldState = vm-state.state;
 +
  cfg = virQEMUDriverGetConfig(driver);

  if (virDomainRevertToSnapshotEnsureACL(snapshot-domain-conn, vm-def) 
  0)
 @@ -14127,6 +14136,14 @@ static int 
 qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
  }
  }

 +if (snap-def-state == VIR_DOMAIN_PMSUSPENDED 
 +(flags  VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING ||
 + flags  VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED)) {
 +virReportError(VIR_ERR_OPERATION_UNSUPPORTED, %s,
 +   _(snapshot of a VM in PMSUSPENDED state cannot be 
 + reverted to a running or paused state));
 
 actually, I think that we need to tackle it differently - we can't
 CREATE a snapshot in the pmsuspended state (just as we can't migrate in
 that state - the mere act of migration is a wakeup event).  So, if you
 eliminate all snapshots in the pmsuspended state as invalid, the set of
 state transitions is smaller.
 
 

I've posted a series that forbids snapshot of pmsuspended guests. My
initiative to post this full rework was so that libvirt would do the
right thing right after the problem in qemu is fixed. With forbidding of
the snapshot we'll need to re-visit this stuff once that qemu is fixed.

Peter




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

Re: [libvirt] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Vasiliy Tolstov
2014-07-21 16:06 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
 I have pushed it to http://dept-info.labri.fr/~thibault/qemu-ipv6 , in
 the tosubmit branch.


Inside packer (i'm try to build some centos 7 boxes) i have errors
Qemu stderr: qemu-system-x86_64: slirp/tcp_input.c:1543: tcp_mss:
Assertion `0' failed.
I'm disable debug when patching. Does i need to reenable it and send
some debug output?

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

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


Re: [libvirt] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Samuel Thibault
Vasiliy Tolstov, le Mon 21 Jul 2014 18:19:17 +0400, a écrit :
 2014-07-21 16:06 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
  I have pushed it to http://dept-info.labri.fr/~thibault/qemu-ipv6 , in
  the tosubmit branch.
 
 
 Inside packer (i'm try to build some centos 7 boxes) i have errors
 Qemu stderr: qemu-system-x86_64: slirp/tcp_input.c:1543: tcp_mss:
 Assertion `0' failed.

Uh?!  Does the switch statement properly have both AF_INET and AF_INET6
cases?

A gdb backtrace would also be useful.

Samuel

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


[libvirt] [PATCH] node_device: HAL: Ignore return value of virStrToLong_ui

2014-07-21 Thread Peter Krempa
Commit 5df813177c3b609a8cf5db26ae94b26d4a40063d forgot to adjust a few
callers of virStrToLong_ui to ignore the returned value in some ancient
parts of the code.
---

Notes:
Pushed under build-braker rule as HAL enabled hosts fail to compile.

 src/node_device/node_device_hal.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/node_device/node_device_hal.c 
b/src/node_device/node_device_hal.c
index 8656b5d..cd7d399 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -151,10 +151,10 @@ gather_pci_cap(LibHalContext *ctx, const char *udi,
 if (get_str_prop(ctx, udi, pci.linux.sysfs_path, sysfs_path) == 0) {
 char *p = strrchr(sysfs_path, '/');
 if (p) {
-(void)virStrToLong_ui(p+1, p, 16, d-pci_dev.domain);
-(void)virStrToLong_ui(p+1, p, 16, d-pci_dev.bus);
-(void)virStrToLong_ui(p+1, p, 16, d-pci_dev.slot);
-(void)virStrToLong_ui(p+1, p, 16, d-pci_dev.function);
+ignore_value(virStrToLong_ui(p+1, p, 16, d-pci_dev.domain));
+ignore_value(virStrToLong_ui(p+1, p, 16, d-pci_dev.bus));
+ignore_value(virStrToLong_ui(p+1, p, 16, d-pci_dev.slot));
+ignore_value(virStrToLong_ui(p+1, p, 16, d-pci_dev.function));
 }

 if (!virPCIGetPhysicalFunction(sysfs_path,
-- 
2.0.0

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


Re: [libvirt] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Vasiliy Tolstov
2014-07-21 18:29 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
 Uh?!  Does the switch statement properly have both AF_INET and AF_INET6
 cases?

 A gdb backtrace would also be useful.


I'm compile 2.1.0-rc2 with
./configure --cc=x86_64-pc-linux-gnu-gcc --prefix=/usr
--libdir=/usr/lib64 --localstatedir=/var --python=/usr/bin/python2
--sysconfdir=/etc --enable-cap-ng --enable-curl --enable-curses
--enable-fdt --enable-guest-agent --enable-guest-base --enable-kvm
--enable-linux-user --enable-modules --enable-seccomp
--enable-stack-protector --enable-system --enable-tcg-interpreter
--enable-tpm --enable-user --enable-uuid --enable-vhdx
--enable-vhost-net --enable-vhost-scsi --disable-brlapi
--disable-glusterfs --disable-rdma --disable-sparse --disable-strip
--disable-werror --disable-xen --disable-xen-pci-passthrough
--disable-xfsctl --with-system-pixman --without-vss-sdk
--without-win-sdk --iasl=/usr/bin/iasl --enable-lzo --enable-snappy
--enable-linux-aio --enable-virtio-blk-data-plane --disable-bluez
--enable-vnc-tls --enable-vnc-ws --disable-libiscsi --enable-vnc-jpeg
--disable-netmap --disable-libnfs --disable-glx --enable-vnc-png
--disable-quorum --disable-rbd --disable-vnc-sasl --disable-sdl
--disable-smartcard-nss --enable-spice --disable-libssh2
--disable-libusb --enable-usb-redir --disable-vde --enable-virtfs
--enable-attr --disable-debug-info --disable-gtk --audio-drv-list=
--target-list=x86_64-linux-user,x86_64-softmmu,i386-linux-user,i386-softmmu

Yes, tcp_mss function have both:
  switch (so-so_ffamily) {
  case AF_INET:
  mss = min(IF_MTU, IF_MRU) - sizeof(struct tcphdr)
+ sizeof(struct ip);
  break;
  case AF_INET6:
  mss = min(IF_MTU, IF_MRU) - sizeof(struct tcphdr)
+ sizeof(struct ip6);
  break;
  default:
  assert(0);
  break;
  }


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

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


Re: [libvirt] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Samuel Thibault
Samuel Thibault, le Mon 21 Jul 2014 16:29:34 +0200, a écrit :
 Vasiliy Tolstov, le Mon 21 Jul 2014 18:19:17 +0400, a écrit :
  2014-07-21 16:06 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
   I have pushed it to http://dept-info.labri.fr/~thibault/qemu-ipv6 , in
   the tosubmit branch.
  
  
  Inside packer (i'm try to build some centos 7 boxes) i have errors
  Qemu stderr: qemu-system-x86_64: slirp/tcp_input.c:1543: tcp_mss:
  Assertion `0' failed.
 
 Uh?!  Does the switch statement properly have both AF_INET and AF_INET6
 cases?
 
 A gdb backtrace would also be useful.

Mmm, I guess this is coming through tcp_connect().  Could you try the
attached patch?

Samuel
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index a1f060b..feae861 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -439,6 +439,7 @@ void tcp_connect(struct socket *inso)
 return;
 }
 so-lhost = inso-lhost;
+so-ffamily = inso-so_ffamily;
 }
 
 tcp_mss(sototcpcb(so), 0);
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Vasiliy Tolstov
2014-07-21 18:29 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
 A gdb backtrace would also be useful.


Can you provide me info how can i get it from running qemu? As i
understand i need to gdb load-symbol and specify debuging simbols (i
have stripped it)
after that i need to attach PID...
?

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

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


Re: [libvirt] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Samuel Thibault
Samuel Thibault, le Mon 21 Jul 2014 16:47:09 +0200, a écrit :
 Samuel Thibault, le Mon 21 Jul 2014 16:29:34 +0200, a écrit :
  Vasiliy Tolstov, le Mon 21 Jul 2014 18:19:17 +0400, a écrit :
   2014-07-21 16:06 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
I have pushed it to http://dept-info.labri.fr/~thibault/qemu-ipv6 , in
the tosubmit branch.
   
   
   Inside packer (i'm try to build some centos 7 boxes) i have errors
   Qemu stderr: qemu-system-x86_64: slirp/tcp_input.c:1543: tcp_mss:
   Assertion `0' failed.
  
  Uh?!  Does the switch statement properly have both AF_INET and AF_INET6
  cases?
  
  A gdb backtrace would also be useful.
 
 Mmm, I guess this is coming through tcp_connect().  Could you try the
 attached patch?

Sorry, I should have tested the build before sending, here it is.

Samuel
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index a1f060b..7fa6173 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -439,6 +439,7 @@ void tcp_connect(struct socket *inso)
 return;
 }
 so-lhost = inso-lhost;
+so-so_ffamily = inso-so_ffamily;
 }
 
 tcp_mss(sototcpcb(so), 0);
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Samuel Thibault
Vasiliy Tolstov, le Mon 21 Jul 2014 18:47:00 +0400, a écrit :
 2014-07-21 18:29 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
  A gdb backtrace would also be useful.
 
 Can you provide me info how can i get it from running qemu? As i
 understand i need to gdb load-symbol and specify debuging simbols (i
 have stripped it)
 after that i need to attach PID...
 ?

For instance, yes, but you probably want to try my patch before.

Samuel

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


Re: [libvirt] [PATCH v1 1/7] configure: Check for statfs

2014-07-21 Thread Daniel P. Berrange
On Thu, Jul 17, 2014 at 06:12:42PM +0200, Michal Privoznik wrote:
 The statfs(2) gets filesystem statistics. Currently, we use it only on
 linux, and leave stub to implement on other platforms. But hey, other
 platforms (like FreeBSD) have statfs() too. If we check it in
 configure we can wider platforms supported. Speaking of FreeBSD, the
 headers to include are of course different: sys/param.h and
 sys/mount.h on the FreeBSD and sys/statfs.h on the Linux. The header
 files are checked too.
 
 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  configure.ac   |  4 ++--
  src/util/virfile.c | 21 ++---
  2 files changed, 16 insertions(+), 9 deletions(-)
 
 diff --git a/configure.ac b/configure.ac
 index 8001e24..68ebf75 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -275,7 +275,7 @@ dnl and various less common threadsafe functions
  AC_CHECK_FUNCS_ONCE([cfmakeraw fallocate geteuid getgid getgrnam_r \
getmntent_r getpwuid_r getuid kill mmap newlocale posix_fallocate \
posix_memalign prlimit regexec sched_getaffinity setgroups setns \
 -  setrlimit symlink sysctlbyname getifaddrs])
 +  setrlimit symlink sysctlbyname getifaddrs statfs])
  
  dnl Availability of pthread functions. Because of $LIB_PTHREAD, we
  dnl cannot use AC_CHECK_FUNCS_ONCE. LIB_PTHREAD and LIBMULTITHREAD
 @@ -316,7 +316,7 @@ dnl Availability of various common headers (non-fatal if 
 missing).
  AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/un.h \
sys/poll.h syslog.h mntent.h net/ethernet.h linux/magic.h \
sys/un.h sys/syscall.h sys/sysctl.h netinet/tcp.h ifaddrs.h \
 -  libtasn1.h sys/ucred.h sys/mount.h])
 +  libtasn1.h sys/ucred.h sys/mount.h sys/param.h sys/statfs.h])
  dnl Check whether endian provides handy macros.
  AC_CHECK_DECLS([htole64], [], [], [[#include endian.h]])
  
 diff --git a/src/util/virfile.c b/src/util/virfile.c
 index 463064c..699b9f8 100644
 --- a/src/util/virfile.c
 +++ b/src/util/virfile.c
 @@ -43,11 +43,15 @@
  # include sys/mman.h
  #endif
  
 -#ifdef __linux__
 -# if HAVE_LINUX_MAGIC_H
 -#  include linux/magic.h
 -# endif
 +#if HAVE_LINUX_MAGIC_H
 +# include linux/magic.h
 +#endif
 +
 +#ifdef HAVE_SYS_STATFS_H
  # include sys/statfs.h
 +#elif defined HAVE_SYS_PARAM_H  defined HAVE_SYS_MOUNT_H
 +# include sys/param.h
 +# include sys/mount.h
  #endif
  
  #if defined(__linux__)  HAVE_DECL_LO_FLAGS_AUTOCLEAR
 @@ -2817,7 +2821,7 @@ int virFilePrintf(FILE *fp, const char *msg, ...)
  }
  
  
 -#ifdef __linux__
 +#ifdef HAVE_STATFS
  
  # ifndef NFS_SUPER_MAGIC
  #  define NFS_SUPER_MAGIC 0x6969

I'm fairly sure these constants are entirely Linux specific, so
although you got it to compile on BSD, I don't think it'll be
returning sensible results.


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

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


Re: [libvirt] [PATCH v1 2/7] Introduce virFileFindHugeTLBFS

2014-07-21 Thread Daniel P. Berrange
On Thu, Jul 17, 2014 at 06:12:43PM +0200, Michal Privoznik wrote:
 This should iterate over mount tab and search for hugetlbfs among with
 looking for the default value of huge pages.
 
 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  src/libvirt_private.syms |   1 +
  src/util/virfile.c   | 155 
 +++
  src/util/virfile.h   |  12 
  3 files changed, 168 insertions(+)
 
 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
 index 8d3671c..44403fd 100644
 --- a/src/libvirt_private.syms
 +++ b/src/libvirt_private.syms
 @@ -1297,6 +1297,7 @@ virFileDirectFdFlag;
  virFileExists;
  virFileFclose;
  virFileFdopen;
 +virFileFindHugeTLBFS;
  virFileFindMountPoint;
  virFileFindResource;
  virFileFindResourceFull;
 diff --git a/src/util/virfile.c b/src/util/virfile.c
 index 699b9f8..e1034b7 100644
 --- a/src/util/virfile.c
 +++ b/src/util/virfile.c

  
 +int
 +virFileGetHugepageSize(const char *path,
 +   unsigned long long *size)

This ought to be in libvirt_private.sym too

  
 +int
 +virFileGetHugepageSize(const char *path,
 +   unsigned long long *size)
 +{
 +/* XXX implement me :-) */
 +VIR_WARN(Trying to get huge page size on %s is not implemented yet.,
 + path);
 +*size = 2048; /* Pure guess */
 +return 0;
 +}

Hmm, seems like we should really report an fatal error here, since
I don't think it makes sense to continue QEMU startup in this scenario.



 +
 +# define PROC_MOUNTS /proc/mounts
 +
 +int
 +virFileFindHugeTLBFS(virHugeTLBFSPtr *ret_fs,
 + size_t *ret_nfs)
 +{
 +int ret = -1;
 +FILE *f = NULL;
 +struct mntent mb;
 +char mntbuf[1024];
 +virHugeTLBFSPtr fs = NULL;
 +size_t nfs = 0;
 +unsigned long long default_hugepagesz;
 +
 +if (virFileGetDefaultHugepageSize(default_hugepagesz)  0)
 +goto cleanup;
 +
 +if (!(f = setmntent(PROC_MOUNTS, r))) {
 +virReportSystemError(errno,
 + _(Unable to open %s),
 + PROC_MOUNTS);
 +goto cleanup;
 +}
 +
 +while (getmntent_r(f, mb, mntbuf, sizeof(mntbuf))) {
 +virHugeTLBFSPtr tmp;
 +
 +if (STRNEQ(mb.mnt_type, hugetlbfs))
 +continue;
 +
 +if (VIR_REALLOC_N(fs, nfs + 1)  0)
 +goto cleanup;
 +
 +tmp = fs[nfs];
 +nfs++;

Perhaps VIR_EXPAND_N would be nicer ?

 +
 +if (VIR_STRDUP(tmp-mnt_dir, mb.mnt_dir)  0)
 +goto cleanup;
 +
 +if (virFileGetHugepageSize(tmp-mnt_dir, tmp-size)  0)
 +goto cleanup;
 +
 +tmp-deflt = tmp-size == default_hugepagesz;
 +}
 +
 +*ret_fs = fs;
 +*ret_nfs = nfs;
 +fs = NULL;
 +nfs = 0;
 +ret = 0;
 +
 + cleanup:
 +endmntent(f);
 +while (nfs)
 +VIR_FREE(fs[--nfs].mnt_dir);
 +VIR_FREE(fs);
 +return ret;
 +}
 +
 +#else
 +
 +int
 +virFileFindHugeTLBFS(virHugeTLBFSPtr *ret_fs,
 + size_t *ret_nfs)
 +{
 +/* XXX implement me :-) */
 +*ret_fs = NULL;
 +*ret_nfs = 0;
 +return 0;
 +}

Again report a fatal error here

 +#endif /* ! defined __linux__  defined HAVE_MNTENT_H 
 +  defined HAVE_GETMNTENT_R */


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

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


Re: [libvirt] [PATCH v1 3/7] qemu: Utilize virFileFindHugeTLBFS

2014-07-21 Thread Daniel P. Berrange
On Thu, Jul 17, 2014 at 06:12:44PM +0200, Michal Privoznik wrote:
 Use better detection of hugetlbfs mount points. Yes, there can be
 multiple mount points each serving different huge page size.
 
 Since we already have ability to override the mount point in the
 qemu.conf file, this crazy backward compatibility code is brought in.
 Now we allow multiple mount points, so the hugetlbfs_mount option
 must take an list of strings (mount points). But previously, it was
 just a string, so we must accept both types now.
 
 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  src/Makefile.am  |   1 +
  src/qemu/qemu_command.c  |  20 
  src/qemu/qemu_conf.c | 122 
 +--
  src/qemu/qemu_conf.h |   9 +++-
  src/qemu/qemu_driver.c   |  39 +++
  src/qemu/qemu_process.c  |  21 +---

Also need to update the augeas files  example config to deal
with list or string.

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

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


Re: [libvirt] [PATCH v1 4/7] virbitmap: Introduce virBitmapDoesIntersect

2014-07-21 Thread Daniel P. Berrange
On Thu, Jul 17, 2014 at 06:12:45PM +0200, Michal Privoznik wrote:
 This internal API just checks if two bitmaps intersect or not.
 
 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  src/libvirt_private.syms |  1 +
  src/util/virbitmap.c | 20 
  src/util/virbitmap.h |  3 +++
  tests/virbitmaptest.c| 26 ++
  4 files changed, 50 insertions(+)

ACK


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

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


Re: [libvirt] [PATCH v1 5/7] domain: Introduce ./hugepages/page/[@size, @unit, @nodeset]

2014-07-21 Thread Daniel P. Berrange
On Thu, Jul 17, 2014 at 06:12:46PM +0200, Michal Privoznik wrote:
 +domain type='qemu'
 +  nameQEMUGuest1/name
 +  uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid
 +  memory unit='KiB'4194304/memory
 +  currentMemory unit='KiB'4194304/currentMemory
 +  memoryBacking
 +hugepages
 +  page size='2048' unit='KiB' nodeset='1'/
 +  page size='1048576' unit='KiB' nodeset='0,2-3'/
 +/hugepages
 +  /memoryBacking
 +  vcpu placement='static'4/vcpu
 +  numatune
 +memory mode='strict' nodeset='0-3'/
 +memnode cellid='3' mode='strict' nodeset='3'/
 +  /numatune
 +  os
 +type arch='i686' machine='pc'hvm/type
 +boot dev='hd'/
 +  /os
 +  cpu
 +numa
 +  cell id='0' cpus='0' memory='1048576'/
 +  cell id='1' cpus='1' memory='1048576'/
 +  cell id='2' cpus='2' memory='1048576'/
 +  cell id='3' cpus='3' memory='1048576'/
 +/numa
 +  /cpu

There's nothing functionally wrong with what you have here, but I'm
wondering if you considered just adding a page size attribute against
the cell element under numa here ? Feels like that might be a bit
less verbose for the XML

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] doc: Explicitly specify how to override spice channel mode

2014-07-21 Thread Peter Krempa
Be more clear that the channel mode= attribute overrides the default
set by defaultMode.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1033704
---
 docs/formatdomain.html.in | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index bb6f710..8950959 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4191,7 +4191,13 @@ qemu-kvm -net nic,model=? /dev/null
   configured, it can be desirable to restrict what
   channels can be run on each port.  This is achieved by
   adding one or more lt;channelgt; elements inside the
-  main lt;graphicsgt; element. Valid channel names
+  main lt;graphicsgt; element and setting the codemode/code
+  attribute to either codesecure/code or codeinsecure/code.
+  Setting the mode attribute overrides the default value as set
+  by the codedefaultMode/code attribute. (Note that specifying
+  codeany/code as mode discards the entry as the channel would
+  inherit the default mode anyways)
+  Valid channel names
   include codemain/code, codedisplay/code,
   codeinputs/code, codecursor/code,
   codeplayback/code, coderecord/code
-- 
2.0.0

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


[libvirt] [PATCH] domtop: Fix build on mingw

2014-07-21 Thread Michal Privoznik
Firstly, there's no sigaction() nor struct sigaction on mingw. We have
to use the one implemented by gnulib (and hence link with gnulib).
Then, for some reason one header file from windows defines ERROR
symbol. Yes it does. Sigh.

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
 examples/domtop/Makefile.am |  6 --
 examples/domtop/domtop.c| 17 +
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/examples/domtop/Makefile.am b/examples/domtop/Makefile.am
index c5cb6c7..dbebb46 100644
--- a/examples/domtop/Makefile.am
+++ b/examples/domtop/Makefile.am
@@ -16,9 +16,11 @@
 ## License along with this library.  If not, see
 ## http://www.gnu.org/licenses/.
 
-INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
+INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
+   -I$(top_builddir)/gnulib/lib -I$(top_srcdir)/gnulib/lib \
+   -I$(top_srcdir)
 LDADDS = $(STATIC_BINARIES) $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la \
-   $(COVERAGE_LDFLAGS)
+ $(top_builddir)/gnulib/lib/libgnu.la $(COVERAGE_LDFLAGS)
 
 noinst_PROGRAMS=domtop
 
diff --git a/examples/domtop/domtop.c b/examples/domtop/domtop.c
index 4ac7889..af5da46 100644
--- a/examples/domtop/domtop.c
+++ b/examples/domtop/domtop.c
@@ -20,6 +20,8 @@
  * Author: Michal Privoznik mpriv...@redhat.com
  */
 
+#include config.h
+
 #include errno.h
 #include getopt.h
 #include libvirt/libvirt.h
@@ -35,6 +37,21 @@
 static bool debug;
 static bool run_top;
 
+/* On mingw, there's a header file that poisons the well:
+ *
+ *
+ *  CC   domtop.o
+ *domtop.c:40:0: warning: ERROR redefined [enabled by default]
+ * #define ERROR(...)  \
+ * ^
+ *In file included from 
/usr/i686-w64-mingw32/sys-root/mingw/include/windows.h:71:0,
+ * from 
/usr/i686-w64-mingw32/sys-root/mingw/include/winsock2.h:23,
+ * from ../../gnulib/lib/unistd.h:48,
+ * from domtop.c:35:
+ * /usr/i686-w64-mingw32/sys-root/mingw/include/wingdi.h:75:0: note: this is 
the location of the previous definition
+ * #define ERROR 0
+ */
+#undef ERROR
 #define ERROR(...)  \
 do {\
 fprintf(stderr, ERROR %s:%d : , __FUNCTION__, __LINE__);  \
-- 
1.8.5.5

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


Re: [libvirt] [PATCH] schema: pool: netfs: Don't enforce slash in glusterfs pool source

2014-07-21 Thread Peter Krempa
On 07/11/14 12:11, Peter Krempa wrote:
 Gluster volumes don't start with a leading slash. Our schema for netfs
 gluster pools enforces it though. Luckily mount.glusterfs skips it.
 Allow a slashless volume name for glusterfs netfs mounts in the schema.
 
 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1101999
 ---
  docs/schemas/basictypes.rng|  6 +++
  docs/schemas/storagepool.rng   | 44 
 +-
  .../pool-netfs-gluster-without-slash.xml   | 12 ++
  3 files changed, 53 insertions(+), 9 deletions(-)
  create mode 100644 
 tests/storagepoolxml2xmlin/pool-netfs-gluster-without-slash.xml
 

Ping. Anybody willing to review? :)

Peter




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 v1 1/7] configure: Check for statfs

2014-07-21 Thread Eric Blake
On 07/21/2014 08:54 AM, Daniel P. Berrange wrote:
 On Thu, Jul 17, 2014 at 06:12:42PM +0200, Michal Privoznik wrote:
 The statfs(2) gets filesystem statistics. Currently, we use it only on
 linux, and leave stub to implement on other platforms. But hey, other
 platforms (like FreeBSD) have statfs() too. If we check it in
 configure we can wider platforms supported. Speaking of FreeBSD, the
 headers to include are of course different: sys/param.h and
 sys/mount.h on the FreeBSD and sys/statfs.h on the Linux. The header
 files are checked too.

 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  configure.ac   |  4 ++--
  src/util/virfile.c | 21 ++---
  2 files changed, 16 insertions(+), 9 deletions(-)


  
  
 -#ifdef __linux__
 +#ifdef HAVE_STATFS
  
  # ifndef NFS_SUPER_MAGIC
  #  define NFS_SUPER_MAGIC 0x6969
 
 I'm fairly sure these constants are entirely Linux specific, so
 although you got it to compile on BSD, I don't think it'll be
 returning sensible results.

Correct. FS Magic numbers are specific to Linux.  Gnulib has a
'mountlist' module that coreutils and findutils share to try and
portably get at file system names for non-Linux systems, but right now
it is GPL, so we'd have to ask gnulib folks if it can be relaxed before
libvirt could benefit from it.  Sadly, mounting of file systems is still
an area of widely varying implementation-specific quirks, where there
are no standard practices between systems.

-- 
Eric Blake   eblake 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 v1 4/7] virbitmap: Introduce virBitmapDoesIntersect

2014-07-21 Thread Eric Blake
On 07/17/2014 10:12 AM, Michal Privoznik wrote:
 This internal API just checks if two bitmaps intersect or not.
 
 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  src/libvirt_private.syms |  1 +
  src/util/virbitmap.c | 20 
  src/util/virbitmap.h |  3 +++
  tests/virbitmaptest.c| 26 ++
  4 files changed, 50 insertions(+)
 
 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
 index 44403fd..256edd5 100644
 --- a/src/libvirt_private.syms
 +++ b/src/libvirt_private.syms
 @@ -1016,6 +1016,7 @@ virBitmapClearBit;
  virBitmapCopy;
  virBitmapCountBits;
  virBitmapDataToString;
 +virBitmapDoesIntersect;

The naming sounds awkward.  Maybe virBitmapIntersects or
virBitmapHasIntersection would be better.

-- 
Eric Blake   eblake 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] domtop: Fix build on mingw

2014-07-21 Thread Eric Blake
On 07/21/2014 09:30 AM, Michal Privoznik wrote:
 Firstly, there's no sigaction() nor struct sigaction on mingw. We have
 to use the one implemented by gnulib (and hence link with gnulib).
 Then, for some reason one header file from windows defines ERROR
 symbol. Yes it does. Sigh.
 
 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  examples/domtop/Makefile.am |  6 --
  examples/domtop/domtop.c| 17 +
  2 files changed, 21 insertions(+), 2 deletions(-)

ACK.

-- 
Eric Blake   eblake 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] doc: Explicitly specify how to override spice channel mode

2014-07-21 Thread Eric Blake
On 07/21/2014 09:21 AM, Peter Krempa wrote:
 Be more clear that the channel mode= attribute overrides the default
 set by defaultMode.
 
 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1033704
 ---
  docs/formatdomain.html.in | 8 +++-
  1 file changed, 7 insertions(+), 1 deletion(-)

ACK.

 
 diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
 index bb6f710..8950959 100644
 --- a/docs/formatdomain.html.in
 +++ b/docs/formatdomain.html.in
 @@ -4191,7 +4191,13 @@ qemu-kvm -net nic,model=? /dev/null
configured, it can be desirable to restrict what
channels can be run on each port.  This is achieved by
adding one or more lt;channelgt; elements inside the
 -  main lt;graphicsgt; element. Valid channel names
 +  main lt;graphicsgt; element and setting the codemode/code
 +  attribute to either codesecure/code or 
 codeinsecure/code.
 +  Setting the mode attribute overrides the default value as set
 +  by the codedefaultMode/code attribute. (Note that 
 specifying
 +  codeany/code as mode discards the entry as the channel 
 would
 +  inherit the default mode anyways)
 +  Valid channel names
include codemain/code, codedisplay/code,
codeinputs/code, codecursor/code,
codeplayback/code, coderecord/code
 

-- 
Eric Blake   eblake 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] schema: pool: netfs: Don't enforce slash in glusterfs pool source

2014-07-21 Thread Eric Blake
On 07/11/2014 04:11 AM, Peter Krempa wrote:
 Gluster volumes don't start with a leading slash. Our schema for netfs
 gluster pools enforces it though. Luckily mount.glusterfs skips it.
 Allow a slashless volume name for glusterfs netfs mounts in the schema.
 
 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1101999
 ---
  docs/schemas/basictypes.rng|  6 +++
  docs/schemas/storagepool.rng   | 44 
 +-
  .../pool-netfs-gluster-without-slash.xml   | 12 ++
  3 files changed, 53 insertions(+), 9 deletions(-)
  create mode 100644 
 tests/storagepoolxml2xmlin/pool-netfs-gluster-without-slash.xml
 
 diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng
 index 5fe3a97..9c9419f 100644
 --- a/docs/schemas/basictypes.rng
 +++ b/docs/schemas/basictypes.rng
 @@ -231,6 +231,12 @@
  /data
/define
 
 +  define name=dirPath
 +data type=string
 +  param 
 name=pattern[a-zA-Z0-9_\.\+\-\\amp;quot;apos;lt;gt;/%]*/param

This allows the empty string...

 +/data
 +  /define
 +
define name=absFilePath
  data type=string
param 
 name=pattern/[a-zA-Z0-9_\.\+\-\\amp;quot;apos;lt;gt;/%,]+/param

...while this required a leading slash and at least one other character.
 I think you want + instead of * in the first pattern.

ACK with that fixed.

-- 
Eric Blake   eblake 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] doc: Explicitly specify how to override spice channel mode

2014-07-21 Thread Peter Krempa
On 07/21/14 18:15, Eric Blake wrote:
 On 07/21/2014 09:21 AM, Peter Krempa wrote:
 Be more clear that the channel mode= attribute overrides the default
 set by defaultMode.

 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1033704
 ---
  docs/formatdomain.html.in | 8 +++-
  1 file changed, 7 insertions(+), 1 deletion(-)
 
 ACK.
 

Pushed; Thanks.

Peter




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

Re: [libvirt] CPU model API (v3)

2014-07-21 Thread Zeeshan Ali (Khattak)
On Fri, Jul 18, 2014 at 12:54 AM, Zeeshan Ali (Khattak)
zeesha...@gnome.org wrote:
 On Tue, Jul 15, 2014 at 11:42 PM, Zeeshan Ali (Khattak)
 zeesha...@gnome.org wrote:
 v3: Two classes for CPU model:
   * CapabilitiesCpuModel
   * DomainCpuModel that derives from CapabilitiesCpuModel.

 Ping! I need these patches to fix the broken case of non-kvm in Boxes
 in a nice way:

 https://bugzilla.gnome.org/show_bug.cgi?id=732680

Hello?

-- 
Regards,

Zeeshan Ali (Khattak)

Befriend GNOME: http://www.gnome.org/friends/

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


Re: [libvirt] [PATCH] schema: pool: netfs: Don't enforce slash in glusterfs pool source

2014-07-21 Thread Peter Krempa
On 07/21/14 18:19, Eric Blake wrote:
 On 07/11/2014 04:11 AM, Peter Krempa wrote:
 Gluster volumes don't start with a leading slash. Our schema for netfs
 gluster pools enforces it though. Luckily mount.glusterfs skips it.
 Allow a slashless volume name for glusterfs netfs mounts in the schema.

 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1101999
 ---
  docs/schemas/basictypes.rng|  6 +++
  docs/schemas/storagepool.rng   | 44 
 +-
  .../pool-netfs-gluster-without-slash.xml   | 12 ++
  3 files changed, 53 insertions(+), 9 deletions(-)
  create mode 100644 
 tests/storagepoolxml2xmlin/pool-netfs-gluster-without-slash.xml

 diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng
 index 5fe3a97..9c9419f 100644
 --- a/docs/schemas/basictypes.rng
 +++ b/docs/schemas/basictypes.rng
 @@ -231,6 +231,12 @@
  /data
/define

 +  define name=dirPath
 +data type=string
 +  param 
 name=pattern[a-zA-Z0-9_\.\+\-\\amp;quot;apos;lt;gt;/%]*/param
 
 This allows the empty string...
 
 +/data
 +  /define
 +
define name=absFilePath
  data type=string
param 
 name=pattern/[a-zA-Z0-9_\.\+\-\\amp;quot;apos;lt;gt;/%,]+/param
 
 ...while this required a leading slash and at least one other character.
  I think you want + instead of * in the first pattern.

Yeah, I forgot to tweak the repeating operator when copying the pattern.

 
 ACK with that fixed.
 

Fixed  pushed;

Thanks.

Peter




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

Re: [libvirt] [PATCHv2 1/2] qemu: snapshot: Forbid taking snapshot in invalid state

2014-07-21 Thread Eric Blake
On 07/21/2014 08:08 AM, Peter Krempa wrote:
 Similarly to 49a3a649a85f9d3d478be355aa8694bce889586a forbid creating
 snapshots in domain states impossible to reach in qemu.
 ---
  src/qemu/qemu_driver.c | 20 
  1 file changed, 20 insertions(+)

ACK.

-- 
Eric Blake   eblake 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] [REPOST 0/8] storage_scsi: Stable SCSI host addressing

2014-07-21 Thread John Ferlan


On 07/18/2014 10:30 AM, Michal Privoznik wrote:
 On 08.07.2014 13:54, John Ferlan wrote:
 Reposting of a series from last month changing only the span version
 in the docs from 1.2.6 to 1.2.7. Previous posting here:

http://www.redhat.com/archives/libvir-list/2014-June/msg00448.html

 The concept still remains the same - rather than rely on the hostNN
 numbers for the scsi_host to remain stable and unique across host reboots
 and/or kernel rebuilds, allow use a combination of the scsi_host's PCI
 address and the value from the hostNN's 'unique_id' file.


 John Ferlan (6):
getAdapterName: check for SCSI_HOST
scsi_backend: Use existing LINUX_SYSFS_SCSI_HOST_PREFIX definition
virutil: Introduce virReadSCSIUniqueId
Add unique_id to nodedev output
scsi_host: Introduce virFindSCSIHostByPCI
getAdapterName: Lookup stable scsi_host

 Osier Yang (2):
virStoragePoolSourceAdapter: Refine the SCSI_HOST adapter name
storage: Introduce parentaddr into virStoragePoolSourceAdapter

   docs/formatnode.html.in|  11 +
   docs/formatstorage.html.in | 143 --
   docs/schemas/basictypes.rng|  24 +-
   docs/schemas/nodedev.rng   |   6 +
   src/conf/node_device_conf.c|  23 +-
   src/conf/node_device_conf.h|   1 +
   src/conf/storage_conf.c| 111 +++-
   src/conf/storage_conf.h|   8 +-
   src/libvirt_private.syms   |   2 +
   src/node_device/node_device_linux_sysfs.c  |   6 +
   src/phyp/phyp_driver.c |   8 +-
   src/storage/storage_backend_scsi.c |  53 +++-
   src/test/test_driver.c |   5 +-
   src/util/virutil.c | 154 +++
   src/util/virutil.h |   8 +
   tests/Makefile.am  |   7 +
   .../pci_8086_27c5_scsi_host_0_unique_id.xml|   8 +
   tests/nodedevxml2xmltest.c |   1 +
   tests/scsihosttest.c   | 308 
 +
   .../pool-scsi-type-scsi-host-stable.xml|  19 ++
   .../pool-scsi-type-scsi-host-stable.xml|  22 ++
   tests/storagepoolxml2xmltest.c |   1 +
   22 files changed, 868 insertions(+), 61 deletions(-)
   create mode 100644 
 tests/nodedevschemadata/pci_8086_27c5_scsi_host_0_unique_id.xml
   create mode 100644 tests/scsihosttest.c
   create mode 100644 
 tests/storagepoolxml2xmlin/pool-scsi-type-scsi-host-stable.xml
   create mode 100644 
 tests/storagepoolxml2xmlout/pool-scsi-type-scsi-host-stable.xml

 
 ACK series, but please see my inline comments.
 
 Michal
 

Thanks for the review.

Adjusted to add error message from 5/8...

Just pushed (now that the power supply for my fiber connection has been
replaced... funny how the kids noticed it first - Dad - the internet is
lost...)

John

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


[libvirt] [PATCH] build: fix build without numactl

2014-07-21 Thread Eric Blake
Under ./configure --without-numactl but with numactl-devel installed,
the build fails with:

../../src/util/virnuma.c: In function 'virNumaNodeIsAvailable':
../../src/util/virnuma.c:407:5: error: implicit declaration of function 
'numa_bitmask_isbitset' [-Werror=implicit-function-declaration]
 return numa_bitmask_isbitset(numa_nodes_ptr, node);
 ^

and other failures, all because the configure results for particular
functions were used without regard to whether libnuma was even being
linked in.

* src/util/virnuma.c (virNumaGetPages): Fix message typo.
(virNumaNodeIsAvailable): Correct build when not using numactl.

Signed-off-by: Eric Blake ebl...@redhat.com
---

Pushing under the build-breaker rule.

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

diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 46f48d2..7a11a3b 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -390,7 +390,7 @@ virNumaGetMaxCPUs(void)
 }


-#ifdef HAVE_NUMA_BITMASK_ISBITSET
+#if WITH_NUMACTL  HAVE_NUMA_BITMASK_ISBITSET
 /**
  * virNumaNodeIsAvailable:
  * @node: node to check
@@ -485,7 +485,7 @@ virNumaGetDistances(int node ATTRIBUTE_UNUSED,
 {
 *distances = NULL;
 *ndistances = 0;
-VIR_DEBUG(NUMA distance information isn't availble on this host);
+VIR_DEBUG(NUMA distance information isn't available on this host);
 return 0;
 }
 #endif
-- 
1.9.3

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


[libvirt] [PATCH] Fix build on non-Linux platforms

2014-07-21 Thread Roman Bogorodskiy
Commit ef48a1b introduced virFindSCSIHostByPCI for Linux and
a stub for other platforms that returns -1 while the function
should return 'char *', so use 'return NULL' instead.

Commit fbd91d4 introduced virReadSCSIUniqueId with the third
argument 'int *result', however the stub for non-Linux patform
uses 'unsigned int *result', so change it to 'int *result'.

Pushed under the build breaker rule.
---
 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 1c6d261..20e9f0e 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -2176,7 +2176,7 @@ virFindFCHostCapableVport(const char *sysfs_prefix)
 int
 virReadSCSIUniqueId(const char *sysfs_prefix ATTRIBUTE_UNUSED,
 int host ATTRIBUTE_UNUSED,
-unsigned int *result ATTRIBUTE_UNUSED)
+int *result ATTRIBUTE_UNUSED)
 {
 virReportSystemError(ENOSYS, %s, _(Not supported on this platform));
 return -1;
@@ -2188,7 +2188,7 @@ virFindSCSIHostByPCI(const char *sysfs_prefix 
ATTRIBUTE_UNUSED,
  unsigned int unique_id ATTRIBUTE_UNUSED)
 {
 virReportSystemError(ENOSYS, %s, _(Not supported on this platform));
-return -1;
+return NULL;
 }
 
 int
-- 
1.9.0

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


[libvirt] [PATCH] storage: logical: drop useless if

2014-07-21 Thread Roman Bogorodskiy
virStorageBackendLogicalCreateVol contains a piece like:

if (vol-target.path != NULL) {
/* A target path passed to CreateVol has no meaning */
VIR_FREE(vol-target.path);
}

The 'if' is useless here, but 'syntax-check' doesn't catch that
because of the comment, so drop the 'if'.
---
 src/storage/storage_backend_logical.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/storage/storage_backend_logical.c 
b/src/storage/storage_backend_logical.c
index ed62c2f..4959985 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -742,10 +742,8 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
 
 vol-type = VIR_STORAGE_VOL_BLOCK;
 
-if (vol-target.path != NULL) {
-/* A target path passed to CreateVol has no meaning */
-VIR_FREE(vol-target.path);
-}
+/* A target path passed to CreateVol has no meaning */
+VIR_FREE(vol-target.path);
 
 if (virAsprintf(vol-target.path, %s/%s,
 pool-def-target.path,
-- 
1.9.0

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


Re: [libvirt] [PATCH] Fix build on non-Linux platforms

2014-07-21 Thread John Ferlan


On 07/21/2014 01:32 PM, Roman Bogorodskiy wrote:
 Commit ef48a1b introduced virFindSCSIHostByPCI for Linux and
 a stub for other platforms that returns -1 while the function
 should return 'char *', so use 'return NULL' instead.
 
 Commit fbd91d4 introduced virReadSCSIUniqueId with the third
 argument 'int *result', however the stub for non-Linux patform
 uses 'unsigned int *result', so change it to 'int *result'.
 
 Pushed under the build breaker rule.
 ---
  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 1c6d261..20e9f0e 100644
 --- a/src/util/virutil.c
 +++ b/src/util/virutil.c
 @@ -2176,7 +2176,7 @@ virFindFCHostCapableVport(const char *sysfs_prefix)
  int
  virReadSCSIUniqueId(const char *sysfs_prefix ATTRIBUTE_UNUSED,
  int host ATTRIBUTE_UNUSED,
 -unsigned int *result ATTRIBUTE_UNUSED)
 +int *result ATTRIBUTE_UNUSED)
  {
  virReportSystemError(ENOSYS, %s, _(Not supported on this platform));
  return -1;
 @@ -2188,7 +2188,7 @@ virFindSCSIHostByPCI(const char *sysfs_prefix 
 ATTRIBUTE_UNUSED,
   unsigned int unique_id ATTRIBUTE_UNUSED)
  {
  virReportSystemError(ENOSYS, %s, _(Not supported on this platform));
 -return -1;
 +return NULL;
  }
  
  int
 

Sorry about that. It's been such a long time since I updated/wrote the
code I cannot remember why the arguments changed.

John

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


Re: [libvirt] [PATCH] storage: logical: drop useless if

2014-07-21 Thread John Ferlan


On 07/21/2014 01:39 PM, Roman Bogorodskiy wrote:
 virStorageBackendLogicalCreateVol contains a piece like:
 
 if (vol-target.path != NULL) {
 /* A target path passed to CreateVol has no meaning */
 VIR_FREE(vol-target.path);
 }
 
 The 'if' is useless here, but 'syntax-check' doesn't catch that
 because of the comment, so drop the 'if'.
 ---
  src/storage/storage_backend_logical.c | 6 ++
  1 file changed, 2 insertions(+), 4 deletions(-)
 

ACK

John

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


Re: [libvirt] [PATCH] Fix build on non-Linux platforms

2014-07-21 Thread Roman Bogorodskiy
  John Ferlan wrote:

 Sorry about that. It's been such a long time since I updated/wrote the
 code I cannot remember why the arguments changed.

No problem, it was a quick fix anyway. :)

Roman Bogorodskiy


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

Re: [libvirt] [PATCH] storage: logical: drop useless if

2014-07-21 Thread Roman Bogorodskiy
  John Ferlan wrote:

 On 07/21/2014 01:39 PM, Roman Bogorodskiy wrote:
  virStorageBackendLogicalCreateVol contains a piece like:
  
  if (vol-target.path != NULL) {
  /* A target path passed to CreateVol has no meaning */
  VIR_FREE(vol-target.path);
  }
  
  The 'if' is useless here, but 'syntax-check' doesn't catch that
  because of the comment, so drop the 'if'.
  ---
   src/storage/storage_backend_logical.c | 6 ++
   1 file changed, 2 insertions(+), 4 deletions(-)
  
 
 ACK

Thanks; pushed.

Roman Bogorodskiy


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

Re: [libvirt] [PATCHv2 2/2] qemu: snapshot: Forbid taking/reverting snapshots in PMSUSPENDED state

2014-07-21 Thread Eric Blake
On 07/21/2014 08:08 AM, Peter Krempa wrote:
 Qemu doesn't currently support them and behaves strangely. Just forbid
 them.
 
 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1079162
 ---
  src/qemu/qemu_driver.c | 15 ---
  1 file changed, 12 insertions(+), 3 deletions(-)
 
 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index 91baa7d..eae23d3 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -13401,9 +13401,14 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
  case VIR_DOMAIN_SHUTDOWN:
  case VIR_DOMAIN_SHUTOFF:
  case VIR_DOMAIN_CRASHED:
 -case VIR_DOMAIN_PMSUSPENDED:
  break;
 
 +case VIR_DOMAIN_PMSUSPENDED:
 +virReportError(VIR_ERR_OPERATION_UNSUPPORTED, %s,
 +   _(qemu doesn't support taking snapshots of 
 + PMSUSPENDED guests));
 +goto cleanup;
 +

This is a bit harsh; a bit nicer might be to take the snapshot anyways
but to have the snapshot be in the running state (as if the act of
taking the snapshot caused a pmwakeup event).  But that's more
complicated, and changes domain state implicitly, while this approach is
vocal to the user why we can't do it (and if qemu ever DOES add support,
we just gate this code by a capability detection bit).

ACK.

-- 
Eric Blake   eblake 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/8] Add iSCSI hostdev pass-through device

2014-07-21 Thread John Ferlan


On 07/11/2014 08:35 AM, John Ferlan wrote:
 https://bugzilla.redhat.com/show_bug.cgi?id=957293
 
 Allow iSCSI hostdev/ devices to be added similarly to the existing
 disk/ devices.  Initially do a little bit of refactoring of the
 hostdev subsys structures to make it easier to model an iSCSI hostdev
 after the SCSI scsi_host.  Although the bulk of the non-structure
 changes are technically unnecessary, it just looked nicer to see
 {usb|pci|scsi}src rather than the longer -source.subsys.u.{usb|pci|scsi}
 in many places in the code.
 
 The end result is the guest will have /dev/sdX devices created.
 
 I have run this code through my Coverity environment and will be
 running the virttest suite over the weekend.
 
 Patches 1-3 are repetitive moves of the various hostdev subsys types
 (USB, PCI, and SCSI) into separate typedefs and then modifying code use
 the Ptr instead of the long union path to each field.  I think I got
 most, but I'm sure there's still a few that could be cleaned up or
 that were added since I started this.
 
 Patch 4 more or less redoes patch 3 and I suppose could be combined. I
 left it separate because it's showing the progression to patch 6. This
 patch uses 'scsihost' to reference the specific portions while still
 using 'scsisrc' to reference the shared portion (which is only sgio).
 
 Patch 5 adds a virConnectPtr since patch 6 will need a way to get the
 secret value for the iSCSI secret/auth in qemuBuildSCSIHostdevDrvStr.
 
 Patch 6 adds the qemu code to handle a new hostdev protocol type
 VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI. The code will mimic the
 network disk (VIR_STORAGE_NET_PROTOCOL_ISCSI) code when making decisions.
 The new 'scsisrc' field 'protocol' will be the decision point. The
 default of VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE was chosen
 over TYPE_SCSI_HOST. The changes were made in this order to reduce
 the size of the patch when the XML is added (patch 8). Most of the
 code was done inline using the iscsisrc-protocol (when the iSCSI code
 had nothing to do). The remaining changes refactored code into SCSIHost 
 and SCSIiSCSI to process the differences.
 
 Patch 7 just refactors domain_conf to add what will be a common routine
 to handle the host/ element network disks.  The iSCSI code will
 reuse the code to have it's own element.
 
 Patch 8 adds the XML, schema, and updates the docs to describe the
 hostdev/ entry as well as of course adding new tests.  The tests
 are a copy/merge of the scsi_host and network iscsi tests to define
 and describe the expected model.
 
 John Ferlan (8):
   hostdev: Introduce virDomainHostdevSubsysUSB
   hostdev: Introduce virDomainHostdevSubsysPCI
   hostdev: Introduce virDomainHostdevSubsysSCSI
   hostdev: Introduce virDomainHostdevSubsysSCSIHost
   Add virConnectPtr for qemuBuildSCSIHostdevDrvStr
   hostdev: Introduce virDomainHostdevSubsysSCSIiSCSI
   domain_conf: Common routine to handle network storage host xml def
   hostdev: Add iSCSI hostdev XML
 
  docs/formatdomain.html.in  | 142 +--
  docs/schemas/domaincommon.rng  |  46 +-
  src/conf/domain_audit.c|  38 +-
  src/conf/domain_conf.c | 463 
 +++--
  src/conf/domain_conf.h |  80 +++-
  src/libxl/libxl_conf.c |   9 +-
  src/libxl/libxl_domain.c   |   5 +-
  src/libxl/libxl_driver.c   |  34 +-
  src/lxc/lxc_cgroup.c   |   4 +-
  src/lxc/lxc_controller.c   |  10 +-
  src/lxc/lxc_driver.c   |  16 +-
  src/qemu/qemu_cgroup.c |  69 +--
  src/qemu/qemu_command.c| 158 ---
  src/qemu/qemu_command.h|   5 +-
  src/qemu/qemu_conf.c   |  20 +-
  src/qemu/qemu_driver.c |   6 +-
  src/qemu/qemu_hotplug.c|  93 +++--
  src/qemu/qemu_hotplug.h|   9 +-
  src/security/security_apparmor.c   |  33 +-
  src/security/security_dac.c|  66 +--
  src/security/security_selinux.c|  64 +--
  src/security/virt-aa-helper.c  |   5 +-
  src/util/virhostdev.c  | 295 +++--
  .../qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.args  |  14 +
  .../qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.xml   |  46 ++
  .../qemuxml2argv-hostdev-scsi-lsi-iscsi.args   |  14 +
  .../qemuxml2argv-hostdev-scsi-lsi-iscsi.xml|  40 ++
  ...emuxml2argv-hostdev-scsi-virtio-iscsi-auth.args |  16 +
  ...qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.xml |  46 ++
  .../qemuxml2argv-hostdev-scsi-virtio-iscsi.args|  16 +
  .../qemuxml2argv-hostdev-scsi-virtio-iscsi.xml |  40 ++
  tests/qemuxml2argvtest.c  

Re: [libvirt] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Vasiliy Tolstov
2014-07-21 18:52 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
 For instance, yes, but you probably want to try my patch before.


Yes, patch fix issue. And now all works fine. Last question - is that
possible to enable/disable ipv4/ipv6 slirp stacks? This is very useful
feature to check dual stack and single stack apps.

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

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


Re: [libvirt] [PATCH 1/8] hostdev: Introduce virDomainHostdevSubsysUSB

2014-07-21 Thread Eric Blake
On 07/11/2014 06:35 AM, John Ferlan wrote:
 Create a separate typedef for the hostdev union data describing USB.
 Then adjust the code to use the new pointer
 
 Signed-off-by: John Ferlan jfer...@redhat.com
 ---
  src/conf/domain_audit.c  |  4 ++--
  src/conf/domain_conf.c   | 50 
 +++-
  src/conf/domain_conf.h   | 22 ++
  src/lxc/lxc_cgroup.c |  4 ++--
  src/lxc/lxc_controller.c | 10 
  src/lxc/lxc_driver.c | 16 ++---
  src/qemu/qemu_cgroup.c   |  4 ++--
  src/qemu/qemu_command.c  | 26 ++---
  src/qemu/qemu_hotplug.c  |  7 +++---
  src/security/security_apparmor.c |  6 ++---
  src/security/security_dac.c  | 12 --
  src/security/security_selinux.c  | 10 
  src/security/virt-aa-helper.c|  5 ++--
  src/util/virhostdev.c| 50 
 +++-
  14 files changed, 104 insertions(+), 122 deletions(-)

Mostly mechanical fallout from the type shuffle.

 
 diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
 index a3d6c67..8277b06 100644
 --- a/src/conf/domain_audit.c
 +++ b/src/conf/domain_audit.c
 @@ -388,6 +388,7 @@ virDomainAuditHostdev(virDomainObjPtr vm, 
 virDomainHostdevDefPtr hostdev,
  char *address = NULL;
  char *device = NULL;
  const char *virt;
 +virDomainHostdevSubsysUSBPtr usbsrc = hostdev-source.subsys.u.usb;
  
  virUUIDFormat(vm-def-uuid, uuidstr);
  if (!(vmname = virAuditEncode(vm, vm-def-name))) {
 @@ -415,8 +416,7 @@ virDomainAuditHostdev(virDomainObjPtr vm, 
 virDomainHostdevDefPtr hostdev,
  break;
  case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
  if (virAsprintfQuiet(address, %.3d.%.3d,
 - hostdev-source.subsys.u.usb.bus,
 - hostdev-source.subsys.u.usb.device)  0) {
 + usbsrc-bus, usbsrc-device)  0) {

I also find it more legible :)


 @@ -10104,15 +10102,18 @@ static int
  virDomainHostdevMatchSubsysUSB(virDomainHostdevDefPtr a,
 virDomainHostdevDefPtr b)
  {
 -if (a-source.subsys.u.usb.bus  a-source.subsys.u.usb.device) {
 +virDomainHostdevSubsysUSBPtr ausbsrc = a-source.subsys.u.usb;
 +virDomainHostdevSubsysUSBPtr busbsrc = b-source.subsys.u.usb;

I read the second variable as bus_b_src, and tried to figure out what
the first one was (was aus a typo for bus?).  Until I saw that you
meant b_usb_src.  Might be worth an _ in the naming to keep it easier to
read.  Or even different naming conventions: first, second.

 +++ b/src/conf/domain_conf.h
 @@ -390,20 +390,24 @@ typedef enum {
  
  VIR_ENUM_DECL(virDomainHostdevSubsysPCIBackend)
  
 +typedef struct _virDomainHostdevSubsysUSB virDomainHostdevSubsysUSB;
 +typedef virDomainHostdevSubsysUSB *virDomainHostdevSubsysUSBPtr;
 +struct _virDomainHostdevSubsysUSB {
 +bool autoAddress; /* bus/device were filled automatically based
 + on vedor/product */

Pre-existing typo, but you might as well fix it during the code motion:

 +unsigned bus;
 +unsigned device;
 +
 +unsigned vendor;
 +unsigned product;
 +};
 +
  typedef struct _virDomainHostdevSubsys virDomainHostdevSubsys;
  typedef virDomainHostdevSubsys *virDomainHostdevSubsysPtr;
  struct _virDomainHostdevSubsys {
  int type; /* enum virDomainHostdevSubsysType */
  union {
 -struct {
 -bool autoAddress; /* bus/device were filled automatically based
 - on vedor/product */

s/vedor/vendor/

ACK with nits fixed.

-- 
Eric Blake   eblake 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 2/8] hostdev: Introduce virDomainHostdevSubsysPCI

2014-07-21 Thread Eric Blake
On 07/11/2014 06:35 AM, John Ferlan wrote:
 Create a separate typedef for the hostdev union data describing PCI.
 Then adjust the code to use the new pointer
 
 Signed-off-by: John Ferlan jfer...@redhat.com
 ---

Starting to get the rebase conflicts here; so yes, reposting the rest of
the series would help review.

  src/conf/domain_audit.c  |  9 
  src/conf/domain_conf.c   | 25 -
  src/conf/domain_conf.h   | 12 ++
  src/libxl/libxl_conf.c   |  9 
  src/libxl/libxl_domain.c |  5 +++--
  src/libxl/libxl_driver.c | 34 ++---
  src/qemu/qemu_cgroup.c   | 24 ++--
  src/qemu/qemu_command.c  | 47 
 ++--
  src/qemu/qemu_hotplug.c  | 11 +-
  src/security/security_apparmor.c | 10 -
  src/security/security_dac.c  | 20 +++--
  src/security/security_selinux.c  | 20 +++--
  src/util/virhostdev.c| 34 -
  13 files changed, 125 insertions(+), 135 deletions(-)

Based solely on visual review for this one:

 @@ -10123,10 +10124,13 @@ static int
  virDomainHostdevMatchSubsysPCI(virDomainHostdevDefPtr a,
 virDomainHostdevDefPtr b)
  {
 -if (a-source.subsys.u.pci.addr.domain == 
 b-source.subsys.u.pci.addr.domain 
 -a-source.subsys.u.pci.addr.bus == b-source.subsys.u.pci.addr.bus 
 -a-source.subsys.u.pci.addr.slot == b-source.subsys.u.pci.addr.slot 
 
 -a-source.subsys.u.pci.addr.function == 
 b-source.subsys.u.pci.addr.function)
 +virDomainHostdevSubsysPCIPtr apcisrc = a-source.subsys.u.pci;
 +virDomainHostdevSubsysPCIPtr bpcisrc = b-source.subsys.u.pci;

Similar to 1/8, naming this 'a_pcisrc' or even 'first' might be easier
to read.

ACK, if the rebase is simple.

-- 
Eric Blake   eblake 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 3/8] hostdev: Introduce virDomainHostdevSubsysSCSI

2014-07-21 Thread Eric Blake
On 07/11/2014 06:35 AM, John Ferlan wrote:
 Create a separate typedef for the hostdev union data describing SCSI
 Then adjust the code to use the new pointer
 
 Signed-off-by: John Ferlan jfer...@redhat.com
 ---
  src/conf/domain_audit.c  |  7 +++---
  src/conf/domain_conf.c   | 40 --
  src/conf/domain_conf.h   | 18 --
  src/qemu/qemu_cgroup.c   |  7 +++---
  src/qemu/qemu_command.c  |  7 +++---
  src/qemu/qemu_conf.c | 18 --
  src/qemu/qemu_hotplug.c  | 12 -
  src/security/security_apparmor.c | 10 +++-
  src/security/security_dac.c  | 20 ++-
  src/security/security_selinux.c  | 20 ++-
  src/util/virhostdev.c| 53 
 
  11 files changed, 98 insertions(+), 114 deletions(-)
 

 @@ -10139,10 +10139,13 @@ static int
  virDomainHostdevMatchSubsysSCSI(virDomainHostdevDefPtr a,
  virDomainHostdevDefPtr b)
  {
 -if (STREQ(a-source.subsys.u.scsi.adapter, 
 b-source.subsys.u.scsi.adapter) 
 -a-source.subsys.u.scsi.bus == b-source.subsys.u.scsi.bus 
 -a-source.subsys.u.scsi.target == b-source.subsys.u.scsi.target 
 -a-source.subsys.u.scsi.unit == b-source.subsys.u.scsi.unit)
 +virDomainHostdevSubsysSCSIPtr ascsisrc = a-source.subsys.u.scsi;
 +virDomainHostdevSubsysSCSIPtr bscsisrc = b-source.subsys.u.scsi;
 +
 +if (STREQ(ascsisrc-adapter, bscsisrc-adapter) 
 +ascsisrc-bus == bscsisrc-bus 
 +ascsisrc-target == bscsisrc-target 
 +ascsisrc-unit == bscsisrc-unit)
  return 1;

Same as 1/8 on naming 'first', 'second'

ACK assuming rebase is trivial.

-- 
Eric Blake   eblake 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] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Samuel Thibault
Vasiliy Tolstov, le Mon 21 Jul 2014 23:22:39 +0400, a écrit :
 2014-07-21 18:52 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
  For instance, yes, but you probably want to try my patch before.
 
 
 Yes, patch fix issue. And now all works fine. Last question - is that
 possible to enable/disable ipv4/ipv6 slirp stacks? This is very useful
 feature to check dual stack and single stack apps.

There's no current support for this, but that could be useful to add
indeed.

Samuel

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


Re: [libvirt] [PATCH 4/8] hostdev: Introduce virDomainHostdevSubsysSCSIHost

2014-07-21 Thread Eric Blake
On 07/11/2014 06:35 AM, John Ferlan wrote:
 Split virDomainHostdevSubsysSCSI further. In preparation for having
 either SCSI or iSCSI data, create a union in virDomainHostdevSubsysSCSI
 to contain just a virDomainHostdevSubsysSCSIHost to describe the
 'scsi_host' host device
 
 Signed-off-by: John Ferlan jfer...@redhat.com
 ---

ACK

-- 
Eric Blake   eblake 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] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Vasiliy Tolstov
2014-07-21 23:49 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
 There's no current support for this, but that could be useful to add
 indeed.


I hit another issue, but may be not related to the patch. In centos 7
(test another boxes) i have running qemu with:
/usr/bin/qemu-system-x86_64 -device virtio-scsi-pci,id=scsi0 -device
scsi-hd,bus=scsi0.0,drive=drive0 -device virtio-net,netdev=user.0
-drive 
if=none,cache=unsafe,id=drive0,discard=unmap,file=output/centos-7-x86_64-qemu/centos-7-x86_64.raw
-display none -netdev user,id=user.0 -boot once=d -redir tcp:3213::22
-m size=1024Mib -name centos-7-x86_64 -machine type=pc-1.0,accel=kvm
-cdrom 
/home/vtolstov/devel/vtolstov/packer-builder/templates/centos/packer_cache/cffdc67bdc73fef02507fdcaff2d9fb7cbc8780ac3c17e862a5451ddbf8bf39d.iso
-vnc 0.0.0.0:47

and try to ssh to localhost -p 3213, but get timeout. in tcpdump i
have send packets but not recieved. inside qemu vm listen for 22 port
on ipv4 and ipv6. Inside vm i see in tcpdump incoming packets but not
outcoming.

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

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


Re: [libvirt] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Samuel Thibault
Vasiliy Tolstov, le Tue 22 Jul 2014 00:12:23 +0400, a écrit :
 2014-07-21 23:49 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
  There's no current support for this, but that could be useful to add
  indeed.
 
 
 I hit another issue, but may be not related to the patch. In centos 7
 (test another boxes) i have running qemu with:
 /usr/bin/qemu-system-x86_64 -device virtio-scsi-pci,id=scsi0 -device
 scsi-hd,bus=scsi0.0,drive=drive0 -device virtio-net,netdev=user.0
 -drive 
 if=none,cache=unsafe,id=drive0,discard=unmap,file=output/centos-7-x86_64-qemu/centos-7-x86_64.raw
 -display none -netdev user,id=user.0 -boot once=d -redir tcp:3213::22
 -m size=1024Mib -name centos-7-x86_64 -machine type=pc-1.0,accel=kvm
 -cdrom 
 /home/vtolstov/devel/vtolstov/packer-builder/templates/centos/packer_cache/cffdc67bdc73fef02507fdcaff2d9fb7cbc8780ac3c17e862a5451ddbf8bf39d.iso
 -vnc 0.0.0.0:47
 
 and try to ssh to localhost -p 3213, but get timeout. in tcpdump i
 have send packets but not recieved. inside qemu vm listen for 22 port
 on ipv4 and ipv6. Inside vm i see in tcpdump incoming packets but not
 outcoming.

It is related to the patch.  I have fixed it, and pushed a newer
tosubmit branch.

Samuel

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


Re: [libvirt] [PATCH 5/8] Add virConnectPtr for qemuBuildSCSIHostdevDrvStr

2014-07-21 Thread Eric Blake
On 07/11/2014 06:35 AM, John Ferlan wrote:
 Add a conn for future patches to be able to grab the secret when
 authenticating an iSCSI host device
 
 Signed-off-by: John Ferlan jfer...@redhat.com
 ---
  src/qemu/qemu_command.c |  5 +++--
  src/qemu/qemu_command.h |  5 +++--
  src/qemu/qemu_driver.c  |  6 +++---
  src/qemu/qemu_hotplug.c | 34 --
  src/qemu/qemu_hotplug.h |  9 ++---
  5 files changed, 35 insertions(+), 24 deletions(-)

I'm not sure if our goal has been to get rid of passing the conn through
by having smarter callbacks, but if it is, this moves in the opposite
direction.  But this patch is clean code-wise, as long as there are no
major design concerns.

-- 
Eric Blake   eblake 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 6/8] hostdev: Introduce virDomainHostdevSubsysSCSIiSCSI

2014-07-21 Thread Eric Blake
On 07/11/2014 06:35 AM, John Ferlan wrote:
 Create the structures and API's to hold and manage the iSCSI host device.
 This extends the 'scsi_host' definitions added in commit id '5c811dce'.
 A future patch will add the XML parsing, but that code requires some
 infrastructure to be in place first in order to handle the differences
 between a 'scsi_host' and an 'iSCSI host' device.
 
 Signed-off-by: John Ferlan jfer...@redhat.com
 ---
  src/conf/domain_audit.c  |  20 +++-
  src/conf/domain_conf.c   |  47 -
  src/conf/domain_conf.h   |  20 
  src/qemu/qemu_cgroup.c   |  35 ---
  src/qemu/qemu_command.c  |  74 ---
  src/qemu/qemu_hotplug.c  |  36 +--
  src/security/security_apparmor.c |   6 ++
  src/security/security_dac.c  |  12 +++
  src/security/security_selinux.c  |  12 +++
  src/util/virhostdev.c| 200 
 +--
  10 files changed, 349 insertions(+), 113 deletions(-)

At this point, it's big enough that I'll wait for a respin to make sure
I'm reviewing it correctly on the latest tree.  But quick comments:

  
 +static void
 +virDomainHostdevSubsysSCSIiSCSIFree(virDomainHostdevSubsysSCSIiSCSIPtr 
 iscsisrc)
 +{
 +if (!iscsisrc)
 +return;
 +VIR_FREE(iscsisrc-path);
 +virStorageNetHostDefFree(iscsisrc-nhosts, iscsisrc-hosts);
 +virStorageAuthDefFree(iscsisrc-auth);
 +iscsisrc-auth = NULL;
 +}

This function doesn't free iscsisrc; typically, we name this type of
function Clear instead of Free.


  static int
 +virDomainHostdevMatchSubsysSCSIiSCSI(virDomainHostdevDefPtr a,
 + virDomainHostdevDefPtr b)
 +{
 +virDomainHostdevSubsysSCSIiSCSIPtr aiscsisrc =
 +a-source.subsys.u.scsi.u.iscsi;
 +virDomainHostdevSubsysSCSIiSCSIPtr biscsisrc =
 +b-source.subsys.u.scsi.u.iscsi;
 +
 +if (STREQ(aiscsisrc-hosts[0].name, biscsisrc-hosts[0].name) 
 +STREQ(aiscsisrc-hosts[0].port, biscsisrc-hosts[0].port) 
 +STREQ(aiscsisrc-path, biscsisrc-path))

'first' and 'second' naming, as in 1/8.

-- 
Eric Blake   eblake 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] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Vasiliy Tolstov
2014-07-22 0:13 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
 It is related to the patch.  I have fixed it, and pushed a newer
 tosubmit branch.


Nothing new in tosubmit branch

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

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


Re: [libvirt] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Samuel Thibault
Vasiliy Tolstov, le Tue 22 Jul 2014 00:19:46 +0400, a écrit :
 2014-07-22 0:13 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
  It is related to the patch.  I have fixed it, and pushed a newer
  tosubmit branch.
 
 Nothing new in tosubmit branch

I have regenerated the branch, you need to check it out again.

Samuel

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


Re: [libvirt] [PATCH 5/8] Add virConnectPtr for qemuBuildSCSIHostdevDrvStr

2014-07-21 Thread John Ferlan


On 07/21/2014 04:14 PM, Eric Blake wrote:
 On 07/11/2014 06:35 AM, John Ferlan wrote:
 Add a conn for future patches to be able to grab the secret when
 authenticating an iSCSI host device

 Signed-off-by: John Ferlan jfer...@redhat.com
 ---
  src/qemu/qemu_command.c |  5 +++--
  src/qemu/qemu_command.h |  5 +++--
  src/qemu/qemu_driver.c  |  6 +++---
  src/qemu/qemu_hotplug.c | 34 --
  src/qemu/qemu_hotplug.h |  9 ++---
  5 files changed, 35 insertions(+), 24 deletions(-)
 
 I'm not sure if our goal has been to get rid of passing the conn through
 by having smarter callbacks, but if it is, this moves in the opposite
 direction.  But this patch is clean code-wise, as long as there are no
 major design concerns.
 


The code follows the VIR_DOMAIN_DEVICE_NET: option.

It's needed for the secret driver.  I do recall we wanted to do
something within the code regarding this type of path, but I forget the
details.

Going to post a v2 shortly.

John

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


[libvirt] [PATCH v2 2/8] hostdev: Introduce virDomainHostdevSubsysPCI

2014-07-21 Thread John Ferlan
Create a separate typedef for the hostdev union data describing PCI.
Then adjust the code to use the new pointer

Signed-off-by: John Ferlan jfer...@redhat.com
---
 src/conf/domain_audit.c  |  9 
 src/conf/domain_conf.c   | 29 +++--
 src/conf/domain_conf.h   | 12 ++
 src/libxl/libxl_conf.c   |  9 
 src/libxl/libxl_domain.c |  6 +++--
 src/libxl/libxl_driver.c | 34 ++---
 src/qemu/qemu_cgroup.c   | 24 ++--
 src/qemu/qemu_command.c  | 47 ++--
 src/qemu/qemu_hotplug.c  | 11 +-
 src/security/security_apparmor.c | 10 -
 src/security/security_dac.c  | 20 +++--
 src/security/security_selinux.c  | 20 +++--
 src/util/virhostdev.c| 34 -
 13 files changed, 128 insertions(+), 137 deletions(-)

diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index 8277b06..d3f0449 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -389,6 +389,7 @@ virDomainAuditHostdev(virDomainObjPtr vm, 
virDomainHostdevDefPtr hostdev,
 char *device = NULL;
 const char *virt;
 virDomainHostdevSubsysUSBPtr usbsrc = hostdev-source.subsys.u.usb;
+virDomainHostdevSubsysPCIPtr pcisrc = hostdev-source.subsys.u.pci;
 
 virUUIDFormat(vm-def-uuid, uuidstr);
 if (!(vmname = virAuditEncode(vm, vm-def-name))) {
@@ -406,10 +407,10 @@ virDomainAuditHostdev(virDomainObjPtr vm, 
virDomainHostdevDefPtr hostdev,
 switch (hostdev-source.subsys.type) {
 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
 if (virAsprintfQuiet(address, %.4x:%.2x:%.2x.%.1x,
- hostdev-source.subsys.u.pci.addr.domain,
- hostdev-source.subsys.u.pci.addr.bus,
- hostdev-source.subsys.u.pci.addr.slot,
- hostdev-source.subsys.u.pci.addr.function)  
0) {
+ pcisrc-addr.domain,
+ pcisrc-addr.bus,
+ pcisrc-addr.slot,
+ pcisrc-addr.function)  0) {
 VIR_WARN(OOM while encoding audit message);
 goto cleanup;
 }
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f23f271..1c8b85a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4260,6 +4260,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
 char *backendStr = NULL;
 int backend;
 int ret = -1;
+virDomainHostdevSubsysPCIPtr pcisrc = def-source.subsys.u.pci;
 
 /* @managed can be read from the xml document - it is always an
  * attribute of the toplevel element, no matter what type of
@@ -4339,7 +4340,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
  has been specified), backendStr);
 goto error;
 }
-def-source.subsys.u.pci.backend = backend;
+pcisrc-backend = backend;
 
 break;
 
@@ -10224,13 +10225,16 @@ virDomainHostdevMatchSubsysUSB(virDomainHostdevDefPtr 
first,
 }
 
 static int
-virDomainHostdevMatchSubsysPCI(virDomainHostdevDefPtr a,
-   virDomainHostdevDefPtr b)
+virDomainHostdevMatchSubsysPCI(virDomainHostdevDefPtr first,
+   virDomainHostdevDefPtr second)
 {
-if (a-source.subsys.u.pci.addr.domain == 
b-source.subsys.u.pci.addr.domain 
-a-source.subsys.u.pci.addr.bus == b-source.subsys.u.pci.addr.bus 
-a-source.subsys.u.pci.addr.slot == b-source.subsys.u.pci.addr.slot 
-a-source.subsys.u.pci.addr.function == 
b-source.subsys.u.pci.addr.function)
+virDomainHostdevSubsysPCIPtr first_pcisrc = first-source.subsys.u.pci;
+virDomainHostdevSubsysPCIPtr second_pcisrc = second-source.subsys.u.pci;
+
+if (first_pcisrc-addr.domain == second_pcisrc-addr.domain 
+first_pcisrc-addr.bus == second_pcisrc-addr.bus 
+first_pcisrc-addr.slot == second_pcisrc-addr.slot 
+first_pcisrc-addr.function == second_pcisrc-addr.function)
 return 1;
 return 0;
 }
@@ -15471,15 +15475,17 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
 bool includeTypeInAddr)
 {
 virDomainHostdevSubsysUSBPtr usbsrc = def-source.subsys.u.usb;
+virDomainHostdevSubsysPCIPtr pcisrc = def-source.subsys.u.pci;
 
 if (def-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI 
-def-source.subsys.u.pci.backend != 
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) {
-const char *backend = 
virDomainHostdevSubsysPCIBackendTypeToString(def-source.subsys.u.pci.backend);
+pcisrc-backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) {
+const char *backend =
+

[libvirt] [PATCH v2 4/8] hostdev: Introduce virDomainHostdevSubsysSCSIHost

2014-07-21 Thread John Ferlan
Split virDomainHostdevSubsysSCSI further. In preparation for having
either SCSI or iSCSI data, create a union in virDomainHostdevSubsysSCSI
to contain just a virDomainHostdevSubsysSCSIHost to describe the
'scsi_host' host device

Signed-off-by: John Ferlan jfer...@redhat.com
---
 src/conf/domain_audit.c  |  8 --
 src/conf/domain_conf.c   | 59 
 src/conf/domain_conf.h   | 14 --
 src/qemu/qemu_cgroup.c   |  9 --
 src/qemu/qemu_command.c  |  7 +++--
 src/qemu/qemu_conf.c | 18 ++--
 src/qemu/qemu_hotplug.c  | 13 +
 src/security/security_apparmor.c |  5 ++--
 src/security/security_dac.c  | 10 ---
 src/security/security_selinux.c  | 10 ---
 src/util/virhostdev.c| 36 
 11 files changed, 113 insertions(+), 76 deletions(-)

diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index 370dc3a..ee9baa2 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -423,14 +423,16 @@ virDomainAuditHostdev(virDomainObjPtr vm, 
virDomainHostdevDefPtr hostdev,
 goto cleanup;
 }
 break;
-case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
+case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
+virDomainHostdevSubsysSCSIHostPtr scsihostsrc = scsisrc-u.host;
 if (virAsprintfQuiet(address, %s:%d:%d:%d,
- scsisrc-adapter, scsisrc-bus,
- scsisrc-target, scsisrc-unit)  0) {
+ scsihostsrc-adapter, scsihostsrc-bus,
+ scsihostsrc-target, scsihostsrc-unit)  0) {
 VIR_WARN(OOM while encoding audit message);
 goto cleanup;
 }
 break;
+}
 default:
 VIR_WARN(Unexpected hostdev type while encoding audit message: 
%d,
  hostdev-source.subsys.type);
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 837f4a8..53bd1d5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1740,7 +1740,7 @@ void virDomainHostdevDefClear(virDomainHostdevDefPtr def)
 break;
 case VIR_DOMAIN_HOSTDEV_MODE_SUBSYS:
 if (def-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI)
-VIR_FREE(def-source.subsys.u.scsi.adapter);
+VIR_FREE(def-source.subsys.u.scsi.u.host.adapter);
 break;
 }
 }
@@ -4025,16 +4025,16 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node,
 }
 
 static int
-virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr node,
-  virDomainHostdevDefPtr def)
+virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode,
+  virDomainHostdevSubsysSCSIPtr 
scsisrc)
 {
 int ret = -1;
 bool got_address = false, got_adapter = false;
 xmlNodePtr cur;
 char *bus = NULL, *target = NULL, *unit = NULL;
-virDomainHostdevSubsysSCSIPtr scsisrc = def-source.subsys.u.scsi;
+virDomainHostdevSubsysSCSIHostPtr scsihostsrc = scsisrc-u.host;
 
-cur = node-children;
+cur = sourcenode-children;
 while (cur != NULL) {
 if (cur-type == XML_ELEMENT_NODE) {
 if (xmlStrEqual(cur-name, BAD_CAST address)) {
@@ -4054,19 +4054,20 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr node,
 goto cleanup;
 }
 
-if (virStrToLong_ui(bus, NULL, 0, scsisrc-bus)  0) {
+if (virStrToLong_ui(bus, NULL, 0, scsihostsrc-bus)  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(cannot parse bus '%s'), bus);
 goto cleanup;
 }
 
-if (virStrToLong_ui(target, NULL, 0, scsisrc-target)  0) {
+if (virStrToLong_ui(target, NULL, 0,
+scsihostsrc-target)  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(cannot parse target '%s'), target);
 goto cleanup;
 }
 
-if (virStrToLong_ui(unit, NULL, 0, scsisrc-unit)  0) {
+if (virStrToLong_ui(unit, NULL, 0, scsihostsrc-unit)  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(cannot parse unit '%s'), unit);
 goto cleanup;
@@ -4080,7 +4081,7 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr node,
  for scsi hostdev source));
 goto cleanup;
 }
-if (!(scsisrc-adapter = virXMLPropString(cur, name))) {
+if (!(scsihostsrc-adapter = virXMLPropString(cur, name))) {
 virReportError(VIR_ERR_XML_ERROR, %s,
_('adapter' 

[libvirt] [PATCH v2 0/8] Add iSCSI hostdev pass-through device

2014-07-21 Thread John Ferlan
Followup/rebase to partially ACK'd pile of changes - figure it's just
as easy for me to keep things together and it's better to see things
in totality...

See: http://www.redhat.com/archives/libvir-list/2014-July/msg00592.html

 * Patches 1-5 were adjusted to use the first_/second_ naming scheme rather
than a/b.
 * Typo for 'vedor' in patch 1 adjusted.
 * Changed name of iSCSIFree to iSCSIClear. 

John Ferlan (8):
  hostdev: Introduce virDomainHostdevSubsysUSB
  hostdev: Introduce virDomainHostdevSubsysPCI
  hostdev: Introduce virDomainHostdevSubsysSCSI
  hostdev: Introduce virDomainHostdevSubsysSCSIHost
  Add virConnectPtr for qemuBuildSCSIHostdevDrvStr
  hostdev: Introduce virDomainHostdevSubsysSCSIiSCSI
  domain_conf: Common routine to handle network storage host xml def
  hostdev: Add iSCSI hostdev XML

 docs/formatdomain.html.in  | 142 +--
 docs/schemas/domaincommon.rng  |  46 +-
 src/conf/domain_audit.c|  38 +-
 src/conf/domain_conf.c | 471 ++---
 src/conf/domain_conf.h |  80 +++-
 src/libxl/libxl_conf.c |   9 +-
 src/libxl/libxl_domain.c   |   6 +-
 src/libxl/libxl_driver.c   |  34 +-
 src/lxc/lxc_cgroup.c   |   4 +-
 src/lxc/lxc_controller.c   |  10 +-
 src/lxc/lxc_driver.c   |  16 +-
 src/qemu/qemu_cgroup.c |  69 +--
 src/qemu/qemu_command.c| 158 ---
 src/qemu/qemu_command.h|   5 +-
 src/qemu/qemu_conf.c   |  20 +-
 src/qemu/qemu_driver.c |   6 +-
 src/qemu/qemu_hotplug.c|  93 ++--
 src/qemu/qemu_hotplug.h|   9 +-
 src/security/security_apparmor.c   |  33 +-
 src/security/security_dac.c|  66 +--
 src/security/security_selinux.c|  64 +--
 src/security/virt-aa-helper.c  |   5 +-
 src/util/virhostdev.c  | 295 +++--
 .../qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.args  |  14 +
 .../qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.xml   |  46 ++
 .../qemuxml2argv-hostdev-scsi-lsi-iscsi.args   |  14 +
 .../qemuxml2argv-hostdev-scsi-lsi-iscsi.xml|  40 ++
 ...emuxml2argv-hostdev-scsi-virtio-iscsi-auth.args |  16 +
 ...qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.xml |  46 ++
 .../qemuxml2argv-hostdev-scsi-virtio-iscsi.args|  16 +
 .../qemuxml2argv-hostdev-scsi-virtio-iscsi.xml |  40 ++
 tests/qemuxml2argvtest.c   |  16 +
 tests/qemuxml2xmltest.c|   5 +
 33 files changed, 1322 insertions(+), 610 deletions(-)
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.xml
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.xml
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.xml
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.xml

-- 
1.9.3

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


[libvirt] [PATCH v2 1/8] hostdev: Introduce virDomainHostdevSubsysUSB

2014-07-21 Thread John Ferlan
Create a separate typedef for the hostdev union data describing USB.
Then adjust the code to use the new pointer

Signed-off-by: John Ferlan jfer...@redhat.com
---
 src/conf/domain_audit.c  |  4 +--
 src/conf/domain_conf.c   | 54 +++-
 src/conf/domain_conf.h   | 22 +---
 src/lxc/lxc_cgroup.c |  4 +--
 src/lxc/lxc_controller.c | 10 +++-
 src/lxc/lxc_driver.c | 16 ++--
 src/qemu/qemu_cgroup.c   |  4 +--
 src/qemu/qemu_command.c  | 26 +--
 src/qemu/qemu_hotplug.c  |  7 +++---
 src/security/security_apparmor.c |  6 ++---
 src/security/security_dac.c  | 12 +++--
 src/security/security_selinux.c  | 10 +---
 src/security/virt-aa-helper.c|  5 ++--
 src/util/virhostdev.c| 50 ++---
 14 files changed, 106 insertions(+), 124 deletions(-)

diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index a3d6c67..8277b06 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -388,6 +388,7 @@ virDomainAuditHostdev(virDomainObjPtr vm, 
virDomainHostdevDefPtr hostdev,
 char *address = NULL;
 char *device = NULL;
 const char *virt;
+virDomainHostdevSubsysUSBPtr usbsrc = hostdev-source.subsys.u.usb;
 
 virUUIDFormat(vm-def-uuid, uuidstr);
 if (!(vmname = virAuditEncode(vm, vm-def-name))) {
@@ -415,8 +416,7 @@ virDomainAuditHostdev(virDomainObjPtr vm, 
virDomainHostdevDefPtr hostdev,
 break;
 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
 if (virAsprintfQuiet(address, %.3d.%.3d,
- hostdev-source.subsys.u.usb.bus,
- hostdev-source.subsys.u.usb.device)  0) {
+ usbsrc-bus, usbsrc-device)  0) {
 VIR_WARN(OOM while encoding audit message);
 goto cleanup;
 }
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1e27165..f23f271 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3807,6 +3807,7 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node,
 xmlNodePtr cur;
 char *startupPolicy = NULL;
 char *autoAddress;
+virDomainHostdevSubsysUSBPtr usbsrc = def-source.subsys.u.usb;
 
 if ((startupPolicy = virXMLPropString(node, startupPolicy))) {
 def-startupPolicy =
@@ -3823,7 +3824,7 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node,
 
 if ((autoAddress = virXMLPropString(node, autoAddress))) {
 if (STREQ(autoAddress, yes))
-def-source.subsys.u.usb.autoAddress = true;
+usbsrc-autoAddress = true;
 VIR_FREE(autoAddress);
 }
 
@@ -3840,8 +3841,7 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node,
 
 if (vendor) {
 got_vendor = true;
-if (virStrToLong_ui(vendor, NULL, 0,
-def-source.subsys.u.usb.vendor)  0) {
+if (virStrToLong_ui(vendor, NULL, 0, usbsrc-vendor)  0) 
{
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(cannot parse vendor id %s), vendor);
 VIR_FREE(vendor);
@@ -3859,7 +3859,7 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node,
 if (product) {
 got_product = true;
 if (virStrToLong_ui(product, NULL, 0,
-def-source.subsys.u.usb.product)  
0) {
+usbsrc-product)  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(cannot parse product %s),
product);
@@ -3877,8 +3877,7 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node,
 
 bus = virXMLPropString(cur, bus);
 if (bus) {
-if (virStrToLong_ui(bus, NULL, 0,
-def-source.subsys.u.usb.bus)  0) {
+if (virStrToLong_ui(bus, NULL, 0, usbsrc-bus)  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(cannot parse bus %s), bus);
 VIR_FREE(bus);
@@ -3893,8 +3892,7 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node,
 
 device = virXMLPropString(cur, device);
 if (device) {
-if (virStrToLong_ui(device, NULL, 0,
-def-source.subsys.u.usb.device)  0) 
 {
+if (virStrToLong_ui(device, NULL, 0, usbsrc-device)  0) 
{
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(cannot parse device %s),
device);
@@ -3917,7 +3915,7 @@ 

[libvirt] [PATCH v2 3/8] hostdev: Introduce virDomainHostdevSubsysSCSI

2014-07-21 Thread John Ferlan
Create a separate typedef for the hostdev union data describing SCSI
Then adjust the code to use the new pointer

Signed-off-by: John Ferlan jfer...@redhat.com
---
 src/conf/domain_audit.c  |  7 +++---
 src/conf/domain_conf.c   | 45 ++
 src/conf/domain_conf.h   | 18 --
 src/qemu/qemu_cgroup.c   |  7 +++---
 src/qemu/qemu_command.c  |  7 +++---
 src/qemu/qemu_conf.c | 18 --
 src/qemu/qemu_hotplug.c  | 12 -
 src/security/security_apparmor.c | 10 +++-
 src/security/security_dac.c  | 20 ++-
 src/security/security_selinux.c  | 20 ++-
 src/util/virhostdev.c| 53 
 11 files changed, 101 insertions(+), 116 deletions(-)

diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index d3f0449..370dc3a 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -390,6 +390,7 @@ virDomainAuditHostdev(virDomainObjPtr vm, 
virDomainHostdevDefPtr hostdev,
 const char *virt;
 virDomainHostdevSubsysUSBPtr usbsrc = hostdev-source.subsys.u.usb;
 virDomainHostdevSubsysPCIPtr pcisrc = hostdev-source.subsys.u.pci;
+virDomainHostdevSubsysSCSIPtr scsisrc = hostdev-source.subsys.u.scsi;
 
 virUUIDFormat(vm-def-uuid, uuidstr);
 if (!(vmname = virAuditEncode(vm, vm-def-name))) {
@@ -424,10 +425,8 @@ virDomainAuditHostdev(virDomainObjPtr vm, 
virDomainHostdevDefPtr hostdev,
 break;
 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
 if (virAsprintfQuiet(address, %s:%d:%d:%d,
- hostdev-source.subsys.u.scsi.adapter,
- hostdev-source.subsys.u.scsi.bus,
- hostdev-source.subsys.u.scsi.target,
- hostdev-source.subsys.u.scsi.unit)  0) {
+ scsisrc-adapter, scsisrc-bus,
+ scsisrc-target, scsisrc-unit)  0) {
 VIR_WARN(OOM while encoding audit message);
 goto cleanup;
 }
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1c8b85a..837f4a8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4032,6 +4032,7 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr node,
 bool got_address = false, got_adapter = false;
 xmlNodePtr cur;
 char *bus = NULL, *target = NULL, *unit = NULL;
+virDomainHostdevSubsysSCSIPtr scsisrc = def-source.subsys.u.scsi;
 
 cur = node-children;
 while (cur != NULL) {
@@ -4053,19 +4054,19 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr node,
 goto cleanup;
 }
 
-if (virStrToLong_ui(bus, NULL, 0, 
def-source.subsys.u.scsi.bus)  0) {
+if (virStrToLong_ui(bus, NULL, 0, scsisrc-bus)  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(cannot parse bus '%s'), bus);
 goto cleanup;
 }
 
-if (virStrToLong_ui(target, NULL, 0, 
def-source.subsys.u.scsi.target)  0) {
+if (virStrToLong_ui(target, NULL, 0, scsisrc-target)  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(cannot parse target '%s'), target);
 goto cleanup;
 }
 
-if (virStrToLong_ui(unit, NULL, 0, 
def-source.subsys.u.scsi.unit)  0) {
+if (virStrToLong_ui(unit, NULL, 0, scsisrc-unit)  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(cannot parse unit '%s'), unit);
 goto cleanup;
@@ -4079,8 +4080,7 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr node,
  for scsi hostdev source));
 goto cleanup;
 }
-if (!(def-source.subsys.u.scsi.adapter =
-  virXMLPropString(cur, name))) {
+if (!(scsisrc-adapter = virXMLPropString(cur, name))) {
 virReportError(VIR_ERR_XML_ERROR, %s,
_('adapter' must be specified for scsi 
hostdev source));
 goto cleanup;
@@ -4261,6 +4261,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
 int backend;
 int ret = -1;
 virDomainHostdevSubsysPCIPtr pcisrc = def-source.subsys.u.pci;
+virDomainHostdevSubsysSCSIPtr scsisrc = def-source.subsys.u.scsi;
 
 /* @managed can be read from the xml document - it is always an
  * attribute of the toplevel element, no matter what type of
@@ -4318,8 +4319,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
 goto error;
 }
 
-if ((def-source.subsys.u.scsi.sgio =
- virDomainDeviceSGIOTypeFromString(sgio)) = 0) {
+if 

[libvirt] [PATCH v2 7/8] domain_conf: Common routine to handle network storage host xml def

2014-07-21 Thread John Ferlan
In preparation for hostdev support for iSCSI and a virStorageNetHostDefPtr,
split out the network disk storage parsing of the 'host' element into a
separate routine.

Signed-off-by: John Ferlan jfer...@redhat.com
---
 src/conf/domain_conf.c | 137 +++--
 1 file changed, 76 insertions(+), 61 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a80530f..0665c27 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4043,6 +4043,79 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node,
 }
 
 static int
+virDomainStorageHostParse(xmlNodePtr node,
+  virStorageNetHostDefPtr *hosts,
+  size_t *nhosts)
+{
+int ret = -1;
+xmlNodePtr child;
+char *transport = NULL;
+virStorageNetHostDef host;
+
+memset(host, 0, sizeof(host));
+
+child = node-children;
+while (child != NULL) {
+if (child-type == XML_ELEMENT_NODE 
+xmlStrEqual(child-name, BAD_CAST host)) {
+
+host.transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
+
+/* transport can be tcp (default), unix or rdma.  */
+if ((transport = virXMLPropString(child, transport))) {
+host.transport = 
virStorageNetHostTransportTypeFromString(transport);
+if (host.transport  0) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(unknown protocol transport type '%s'),
+   transport);
+goto cleanup;
+}
+}
+
+host.socket = virXMLPropString(child, socket);
+
+if (host.transport == VIR_STORAGE_NET_HOST_TRANS_UNIX 
+host.socket == NULL) {
+virReportError(VIR_ERR_XML_ERROR, %s,
+   _(missing socket for unix transport));
+goto cleanup;
+}
+
+if (host.transport != VIR_STORAGE_NET_HOST_TRANS_UNIX 
+host.socket != NULL) {
+virReportError(VIR_ERR_XML_ERROR,
+   _(transport '%s' does not support 
+ socket attribute),
+   transport);
+goto cleanup;
+}
+
+VIR_FREE(transport);
+
+if (host.transport != VIR_STORAGE_NET_HOST_TRANS_UNIX) {
+if (!(host.name = virXMLPropString(child, name))) {
+virReportError(VIR_ERR_XML_ERROR, %s,
+   _(missing name for host));
+goto cleanup;
+}
+
+host.port = virXMLPropString(child, port);
+}
+
+if (VIR_APPEND_ELEMENT(*hosts, *nhosts, host)  0)
+goto cleanup;
+}
+child = child-next;
+}
+ret = 0;
+
+ cleanup:
+virStorageNetHostDefClear(host);
+VIR_FREE(transport);
+return ret;
+}
+
+static int
 virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode,
   virDomainHostdevSubsysSCSIPtr 
scsisrc)
 {
@@ -5033,13 +5106,8 @@ int
 virDomainDiskSourceParse(xmlNodePtr node,
  virStorageSourcePtr src)
 {
-char *protocol = NULL;
-char *transport = NULL;
-virStorageNetHostDef host;
-xmlNodePtr child;
 int ret = -1;
-
-memset(host, 0, sizeof(host));
+char *protocol = NULL;
 
 switch ((virStorageType)src-type) {
 case VIR_STORAGE_TYPE_FILE:
@@ -5092,59 +5160,8 @@ virDomainDiskSourceParse(xmlNodePtr node,
 tmp[0] = '\0';
 }
 
-child = node-children;
-while (child != NULL) {
-if (child-type == XML_ELEMENT_NODE 
-xmlStrEqual(child-name, BAD_CAST host)) {
-
-host.transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
-
-/* transport can be tcp (default), unix or rdma.  */
-if ((transport = virXMLPropString(child, transport))) {
-host.transport = 
virStorageNetHostTransportTypeFromString(transport);
-if (host.transport  0) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-   _(unknown protocol transport type 
'%s'),
-   transport);
-goto cleanup;
-}
-}
-
-host.socket = virXMLPropString(child, socket);
-
-if (host.transport == VIR_STORAGE_NET_HOST_TRANS_UNIX 
-host.socket == NULL) {
-virReportError(VIR_ERR_XML_ERROR, %s,
-   _(missing socket for unix transport));
-goto cleanup;
-}
-
-if (host.transport != VIR_STORAGE_NET_HOST_TRANS_UNIX 
-host.socket != NULL) {
-   

[libvirt] [PATCH v2 6/8] hostdev: Introduce virDomainHostdevSubsysSCSIiSCSI

2014-07-21 Thread John Ferlan
Create the structures and API's to hold and manage the iSCSI host device.
This extends the 'scsi_host' definitions added in commit id '5c811dce'.
A future patch will add the XML parsing, but that code requires some
infrastructure to be in place first in order to handle the differences
between a 'scsi_host' and an 'iSCSI host' device.

Signed-off-by: John Ferlan jfer...@redhat.com
---
 src/conf/domain_audit.c  |  20 +++-
 src/conf/domain_conf.c   |  47 -
 src/conf/domain_conf.h   |  20 
 src/qemu/qemu_cgroup.c   |  35 ---
 src/qemu/qemu_command.c  |  74 ---
 src/qemu/qemu_hotplug.c  |  36 +--
 src/security/security_apparmor.c |   6 ++
 src/security/security_dac.c  |  12 +++
 src/security/security_selinux.c  |  12 +++
 src/util/virhostdev.c| 200 +--
 10 files changed, 349 insertions(+), 113 deletions(-)

diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index ee9baa2..3ad58b0 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -424,12 +424,22 @@ virDomainAuditHostdev(virDomainObjPtr vm, 
virDomainHostdevDefPtr hostdev,
 }
 break;
 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: {
-virDomainHostdevSubsysSCSIHostPtr scsihostsrc = scsisrc-u.host;
-if (virAsprintfQuiet(address, %s:%d:%d:%d,
- scsihostsrc-adapter, scsihostsrc-bus,
- scsihostsrc-target, scsihostsrc-unit)  0) {
-VIR_WARN(OOM while encoding audit message);
+if (scsisrc-protocol ==
+VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
+/* Follow virDomainAuditDisk  virDomainAuditGenericDev
+ * and don't audit the networked device.
+ */
 goto cleanup;
+} else {
+virDomainHostdevSubsysSCSIHostPtr scsihostsrc =
+scsisrc-u.host;
+if (virAsprintfQuiet(address, %s:%d:%d:%d,
+ scsihostsrc-adapter, scsihostsrc-bus,
+ scsihostsrc-target,
+ scsihostsrc-unit)  0) {
+VIR_WARN(OOM while encoding audit message);
+goto cleanup;
+}
 }
 break;
 }
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 53bd1d5..a80530f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1709,6 +1709,17 @@ virDomainHostdevDefPtr virDomainHostdevDefAlloc(void)
 return def;
 }
 
+static void
+virDomainHostdevSubsysSCSIiSCSIClear(virDomainHostdevSubsysSCSIiSCSIPtr 
iscsisrc)
+{
+if (!iscsisrc)
+return;
+VIR_FREE(iscsisrc-path);
+virStorageNetHostDefFree(iscsisrc-nhosts, iscsisrc-hosts);
+virStorageAuthDefFree(iscsisrc-auth);
+iscsisrc-auth = NULL;
+}
+
 void virDomainHostdevDefClear(virDomainHostdevDefPtr def)
 {
 if (!def)
@@ -1739,8 +1750,15 @@ void virDomainHostdevDefClear(virDomainHostdevDefPtr def)
 }
 break;
 case VIR_DOMAIN_HOSTDEV_MODE_SUBSYS:
-if (def-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI)
-VIR_FREE(def-source.subsys.u.scsi.u.host.adapter);
+if (def-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
+virDomainHostdevSubsysSCSIPtr scsisrc = def-source.subsys.u.scsi;
+if (scsisrc-protocol ==
+VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
+virDomainHostdevSubsysSCSIiSCSIClear(scsisrc-u.iscsi);
+} else {
+VIR_FREE(scsisrc-u.host.adapter);
+}
+}
 break;
 }
 }
@@ -4320,8 +4338,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
 }
 
 if (sgio) {
-if (def-source.subsys.type !=
-VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
+if (def-source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
 virReportError(VIR_ERR_XML_ERROR, %s,
_(sgio is only supported for scsi host device));
 goto error;
@@ -10265,6 +10282,22 @@ 
virDomainHostdevMatchSubsysSCSIHost(virDomainHostdevDefPtr first,
 }
 
 static int
+virDomainHostdevMatchSubsysSCSIiSCSI(virDomainHostdevDefPtr first,
+ virDomainHostdevDefPtr second)
+{
+virDomainHostdevSubsysSCSIiSCSIPtr first_iscsisrc =
+first-source.subsys.u.scsi.u.iscsi;
+virDomainHostdevSubsysSCSIiSCSIPtr second_iscsisrc =
+second-source.subsys.u.scsi.u.iscsi;
+
+if (STREQ(first_iscsisrc-hosts[0].name, second_iscsisrc-hosts[0].name) 
+STREQ(first_iscsisrc-hosts[0].port, second_iscsisrc-hosts[0].port) 
+STREQ(first_iscsisrc-path, second_iscsisrc-path))
+return 1;
+return 0;
+}
+
+static int
 

[libvirt] [PATCH v2 5/8] Add virConnectPtr for qemuBuildSCSIHostdevDrvStr

2014-07-21 Thread John Ferlan
Add a conn for future patches to be able to grab the secret when
authenticating an iSCSI host device

Signed-off-by: John Ferlan jfer...@redhat.com
---
 src/qemu/qemu_command.c |  5 +++--
 src/qemu/qemu_command.h |  5 +++--
 src/qemu/qemu_driver.c  |  6 +++---
 src/qemu/qemu_hotplug.c | 34 --
 src/qemu/qemu_hotplug.h |  9 ++---
 5 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fa9c72f..372ad22 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5125,7 +5125,8 @@ qemuBuildUSBHostdevUSBDevStr(virDomainHostdevDefPtr dev)
 }
 
 char *
-qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
+qemuBuildSCSIHostdevDrvStr(virConnectPtr conn ATTRIBUTE_UNUSED,
+   virDomainHostdevDefPtr dev,
virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED,
qemuBuildCommandLineCallbacksPtr callbacks)
 {
@@ -8999,7 +9000,7 @@ qemuBuildCommandLine(virConnectPtr conn,
 char *drvstr;
 
 virCommandAddArg(cmd, -drive);
-if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev, qemuCaps, 
callbacks)))
+if (!(drvstr = qemuBuildSCSIHostdevDrvStr(conn, hostdev, 
qemuCaps, callbacks)))
 goto error;
 virCommandAddArg(cmd, drvstr);
 VIR_FREE(drvstr);
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index cf51056..b71e964 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -170,10 +170,11 @@ char * qemuBuildUSBHostdevDevStr(virDomainDefPtr def,
  virDomainHostdevDefPtr dev,
  virQEMUCapsPtr qemuCaps);
 
-char * qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
+char * qemuBuildSCSIHostdevDrvStr(virConnectPtr conn,
+  virDomainHostdevDefPtr dev,
   virQEMUCapsPtr qemuCaps,
   qemuBuildCommandLineCallbacksPtr callbacks)
-ATTRIBUTE_NONNULL(3);
+ATTRIBUTE_NONNULL(4);
 char * qemuBuildSCSIHostdevDevStr(virDomainDefPtr def,
   virDomainHostdevDefPtr dev,
   virQEMUCapsPtr qemuCaps);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1782913..77af34d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6472,7 +6472,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm,
 break;
 
 case VIR_DOMAIN_DEVICE_HOSTDEV:
-ret = qemuDomainAttachHostDevice(driver, vm,
+ret = qemuDomainAttachHostDevice(dom-conn, driver, vm,
  dev-data.hostdev);
 if (!ret)
 dev-data.hostdev = NULL;
@@ -6544,10 +6544,10 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm,
 ret = qemuDomainDetachLease(driver, vm, dev-data.lease);
 break;
 case VIR_DOMAIN_DEVICE_NET:
-ret = qemuDomainDetachNetDevice(driver, vm, dev);
+ret = qemuDomainDetachNetDevice(dom-conn, driver, vm, dev);
 break;
 case VIR_DOMAIN_DEVICE_HOSTDEV:
-ret = qemuDomainDetachHostDevice(driver, vm, dev);
+ret = qemuDomainDetachHostDevice(dom-conn, driver, vm, dev);
 break;
 case VIR_DOMAIN_DEVICE_CHR:
 ret = qemuDomainDetachChrDevice(driver, vm, dev-data.chr);
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 7df5832..6773d50 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -860,7 +860,7 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
  * netdev-specific code as appropriate), then also added to
  * the nets list (see cleanup:) if successful.
  */
-ret = qemuDomainAttachHostDevice(driver, vm,
+ret = qemuDomainAttachHostDevice(conn, driver, vm,
  virDomainNetGetActualHostdev(net));
 goto cleanup;
 }
@@ -1547,7 +1547,8 @@ qemuDomainAttachHostUSBDevice(virQEMUDriverPtr driver,
 }
 
 static int
-qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr driver,
+qemuDomainAttachHostSCSIDevice(virConnectPtr conn,
+   virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainHostdevDefPtr hostdev)
 {
@@ -1594,7 +1595,7 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr driver,
 if (qemuAssignDeviceHostdevAlias(vm-def, hostdev, -1)  0)
 goto cleanup;
 
-if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev, priv-qemuCaps,
+if (!(drvstr = qemuBuildSCSIHostdevDrvStr(conn, hostdev, priv-qemuCaps,
   buildCommandLineCallbacks)))
 goto cleanup;
 
@@ -1642,7 +1643,8 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr driver,
 return ret;
 }
 
-int qemuDomainAttachHostDevice(virQEMUDriverPtr 

[libvirt] [PATCH v2 8/8] hostdev: Add iSCSI hostdev XML

2014-07-21 Thread John Ferlan
Introduce a new structure to handle an iSCSI host device based on the
existing virDomainHostdevSubsysSCSI by adding a protocol='iscsi' to
the source/ element.  The hostdev structure mimics the existing
disk/ element for an iSCSI device (network) device. New XML is:

  hostdev mode='subsystem' type='scsi' managed='yes'
auth username='myname'
  secret type='iscsi' usage='mycluster_myname'/
/auth
source protocol='iscsi' name='iqn.1992-01.com.example'
  host name='example.org' port='3260'/
/source
address type='drive' controller='0' bus='0' target='2' unit='5'/
  /hostdev

The controller element will mimic the existing scsi_host code insomuch
as when 'lsi' and 'virtio-scsi' are used.

Signed-off-by: John Ferlan jfer...@redhat.com
---
 docs/formatdomain.html.in  | 142 ---
 docs/schemas/domaincommon.rng  |  46 ++-
 src/conf/domain_conf.c | 152 ++---
 .../qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.args  |  14 ++
 .../qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.xml   |  46 +++
 .../qemuxml2argv-hostdev-scsi-lsi-iscsi.args   |  14 ++
 .../qemuxml2argv-hostdev-scsi-lsi-iscsi.xml|  40 ++
 ...emuxml2argv-hostdev-scsi-virtio-iscsi-auth.args |  16 +++
 ...qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.xml |  46 +++
 .../qemuxml2argv-hostdev-scsi-virtio-iscsi.args|  16 +++
 .../qemuxml2argv-hostdev-scsi-virtio-iscsi.xml |  40 ++
 tests/qemuxml2argvtest.c   |  16 +++
 tests/qemuxml2xmltest.c|   5 +
 13 files changed, 524 insertions(+), 69 deletions(-)
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.xml
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.xml
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.xml
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 8950959..918ba3c 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2802,57 +2802,107 @@
   lt;/devicesgt;
   .../pre
 
+
+por:/p
+
+pre
+  ...
+  lt;devicesgt;
+lt;hostdev mode='subsystem' type='scsi'gt;
+  lt;source protocol='iscsi' 
name='iqn.2014-08.com.example:iscsi-nopool/1'gt;
+lt;host name='example.com' port='3260'/gt;
+  lt;/sourcegt;
+  lt;auth username='myuser'gt;
+lt;secret type='iscsi' usage='libvirtiscsi'/gt;
+  lt;/authgt;
+  lt;address type='drive' controller='0' bus='0' target='0' unit='0'/gt;
+lt;/hostdevgt;
+  lt;/devicesgt;
+  .../pre
+
 dl
   dtcodehostdev/code/dt
   ddThe codehostdev/code element is the main container for describing
-host devices. For usb device passthrough codemode/code is always
-subsystem and codetype/code is usb for a USB device, pci
-for a PCI device and scsi for a SCSI device. When
-codemanaged/code is yes for a PCI
-device, it is detached from the host before being passed on to
-the guest, and reattached to the host after the guest exits.
-If codemanaged/code is omitted or no, and for USB
-devices, the user is responsible to
-call codevirNodeDeviceDettach/code (or codevirsh
-nodedev-dettach/code) before starting the guest or
-hot-plugging the device,
-and codevirNodeDeviceReAttach/code (or codevirsh
-nodedev-reattach/code) after hot-unplug or stopping the
-guest. For SCSI device, user is responsible to make sure the device
-is not used by host.
-The optional codesgio/code (span class=sincesince 1.0.6/span)
-attribute indicates whether the kernel will filter unprivileged
-SG_IO commands for the disk, valid settings are filtered or
-unfiltered. Defaults to filtered.
+host devices. For each device, the codemode/code is always
+subsystem and the codetype/code is one of the following values
+with additional attributes noted.
+dl
+  dtusb/dt
+  ddFor USB devices, the user is responsible to call
+codevirNodeDeviceDettach/code (or
+codevirsh nodedev-dettach/code) before starting the guest
+or hot-plugging the device and codevirNodeDeviceReAttach/code
+(or codevirsh nodedev-reattach/code) after hot-unplug or
+stopping the guest.
+  /dd
+  dtpci/dt
+  ddFor PCI devices, when codemanaged/code is yes 

Re: [libvirt] [Qemu-devel] ipv6 slirp network

2014-07-21 Thread Samuel Thibault
Samuel Thibault, le Mon 21 Jul 2014 22:30:40 +0200, a écrit :
 Vasiliy Tolstov, le Tue 22 Jul 2014 00:19:46 +0400, a écrit :
  2014-07-22 0:13 GMT+04:00 Samuel Thibault samuel.thiba...@gnu.org:
   It is related to the patch.  I have fixed it, and pushed a newer
   tosubmit branch.
  
  Nothing new in tosubmit branch
 
 I have regenerated the branch, you need to check it out again.

Alternatively, you can track the parameters branch, which I don't
regenerate.

Samuel

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


Re: [libvirt] [PATCH] leaseshelper: add enhancements to support all events

2014-07-21 Thread Nehal J Wani
On Thu, Jul 17, 2014 at 9:38 PM, Eric Blake ebl...@redhat.com wrote:
 On 07/17/2014 09:18 AM, Peter Krempa wrote:

 A second issue that comes into my mind is compatibility with already
 existing files. Does this work when you already have a lease file? (I
 didn't try it, I'm just asking).

 If we use the --leasefile-ro option, then although this method will
 work, but no, the lease file will *not* be read/written at all. So
 even if an old one exists, its of no use.
 But then again, the use of --leasefile-ro is mandatory, so that all
 events are captured by our helper program. For example, renew of a
 lease.

 My concerns are whether this will work in the case you already used the
 leases helper as the patch is adding a few fields to the stored format.

 In particular, this scenario MUST work:

 A user installs libvirt 1.2.6, and starts a guest (which creates a
 leases file and longrunning helper app).  Then the user upgrades to
 libvirt 1.2.7 and restarts libvirtd.  The new libvirt MUST be able to
 interact with the running guest that is still using the older-style
 leases file and helper app, with no loss of behavior to the guest.

 Also, this scenario MUST work:

 A user installs libvirt 1.2.6.  Then they upgrade to libvirt 1.2.7, but
 without restarting libvirtd.  Then they start a guest.  Note that the
 upgrade means that the leaseshelper application that will be started is
 the 1.2.7 build, but the command line to start it will be triggered by
 the 1.2.6 libvirtd.  The new helper must do everything that the old
 helper did, so that the old libvirtd does not have any hiccups in operation.

 The easiest way to ensure that both directions of version mismatch are
 well-behaved is to make sure that either side can be newer than the
 other, that the changes are purely additive in nature, and that there
 are sane defaults in place in the newer code when dealing with the older
 data that lacks the additions.  Also, while upgrade is a required
 scenario, downgrade generally is not (going from 1.2.7 back to 1.2.6
 while a guest is still running, or expecting 1.2.7 libvirtd to be able
 to use 1.2.6 leaseshelper, is nice if it works but not a showstopper if
 it doesn't).

This patch only adds functionality, and is backwards compatible with
the version of leases file generated by older version of leaseshelper.
Anyway, the older version wasn't much helpful after the lease expired.
This patch rectifies it. I'll send a v2 shortly.



Regards,
Nehal J Wani

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


[libvirt] [PATCH v2] leaseshelper: improvements to support all events

2014-07-21 Thread Nehal J Wani
This patch enables the helper program to detect event(s) triggered when there
is a change in lease length or expiry and client-id. This transfers complete
control of leases database to libvirt and obsoletes use of the lease database
file (network-name.leases). That file will not be created, read, or written.
This is achieved by adding the option --leasefile-ro to dnsmasq and passing a
custom env var to leaseshelper, which helps us map events related to leases
with their corresponding network bridges, no matter what the event be.

Also, this requires the addition of a new non-lease entry in our custom lease
database: server-duid. It is required to identify a DHCPv6 server.

Now that dnsmasq doesn't maintain its own leases database, it relies on our
helper program to tell it about previous leases and server duid. Thus, this
patch makes our leases program honor an extra action: init, in which it sends
the known info in a particular format to dnsmasq by printing it to stdout.

---
 This is compatible with libvirt 1.2.6 as only additions have been
 introduced, and the old leases file (*.staus) will still be supported.

 v1: https://www.redhat.com/archives/libvir-list/2014-July/msg00568.html

 src/network/bridge_driver.c |   7 ++
 src/network/leaseshelper.c  | 152 +---
 2 files changed, 136 insertions(+), 23 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 6a2e760..4363cd8 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -1289,7 +1289,10 @@ networkBuildDhcpDaemonCommandLine(virNetworkObjPtr 
network,
 
 cmd = virCommandNew(dnsmasqCapsGetBinaryPath(caps));
 virCommandAddArgFormat(cmd, --conf-file=%s, configfile);
+/* Libvirt gains full control of leases database */
+virCommandAddArgFormat(cmd, --leasefile-ro);
 virCommandAddArgFormat(cmd, --dhcp-script=%s, leaseshelper_path);
+virCommandAddEnvPair(cmd, VIR_BRIDGE_NAME, network-def-bridge);
 
 *cmdout = cmd;
 ret = 0;
@@ -3432,6 +3435,10 @@ networkGetDHCPLeases(virNetworkPtr network,
 goto error;
 }
 
+/* Ignore server-duid. It's not part of a lease */
+if (virJSONValueObjectHasKey(lease_tmp, server-duid))
+continue;
+
 if (!(mac_tmp = virJSONValueObjectGetString(lease_tmp, 
mac-address))) {
 /* leaseshelper program guarantees that lease will be stored only 
if
  * mac-address is known otherwise not */
diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c
index e4b5283..cc4b4ac 100644
--- a/src/network/leaseshelper.c
+++ b/src/network/leaseshelper.c
@@ -50,6 +50,12 @@
  */
 #define VIR_NETWORK_DHCP_LEASE_FILE_SIZE_MAX (32 * 1024 * 1024)
 
+/*
+ * Use this when passing possibly-NULL strings to printf-a-likes.
+ * Required for unknown parameters during init call.
+ */
+#define EMPTY_STR(s) ((s) ? (s) : *)
+
 static const char *program_name;
 
 /* Display version information. */
@@ -65,7 +71,7 @@ usage(int status)
 if (status) {
 fprintf(stderr, _(%s: try --help for more details\n), program_name);
 } else {
-printf(_(Usage: %s add|old|del mac|clientid ip [hostname]\n
+printf(_(Usage: %s add|old|del|init mac|clientid ip [hostname]\n
  Designed for use with 'dnsmasq --dhcp-script'\n
  Refer to man page of dnsmasq for more details'\n),
program_name);
@@ -89,6 +95,7 @@ enum virLeaseActionFlags {
 VIR_LEASE_ACTION_ADD,   /* Create new lease */
 VIR_LEASE_ACTION_OLD,   /* Lease already exists, renew it */
 VIR_LEASE_ACTION_DEL,   /* Delete the lease */
+VIR_LEASE_ACTION_INIT,  /* Tell dnsmasq of existing leases on restart 
*/
 
 VIR_LEASE_ACTION_LAST
 };
@@ -96,7 +103,7 @@ enum virLeaseActionFlags {
 VIR_ENUM_DECL(virLeaseAction);
 
 VIR_ENUM_IMPL(virLeaseAction, VIR_LEASE_ACTION_LAST,
-  add, old, del);
+  add, old, del, init);
 
 int
 main(int argc, char **argv)
@@ -105,6 +112,7 @@ main(int argc, char **argv)
 char *pid_file = NULL;
 char *lease_entries = NULL;
 char *custom_lease_file = NULL;
+char *server_duid = NULL;
 const char *ip = NULL;
 const char *mac = NULL;
 const char *iaid = virGetEnvAllowSUID(DNSMASQ_IAID);
@@ -112,20 +120,26 @@ main(int argc, char **argv)
 const char *interface = virGetEnvAllowSUID(DNSMASQ_INTERFACE);
 const char *exptime_tmp = virGetEnvAllowSUID(DNSMASQ_LEASE_EXPIRES);
 const char *hostname = virGetEnvAllowSUID(DNSMASQ_SUPPLIED_HOSTNAME);
+const char *server_duid_env = virGetEnvAllowSUID(DNSMASQ_SERVER_DUID);
 const char *leases_str = NULL;
 long long currtime = 0;
 long long expirytime = 0;
 size_t i = 0;
+size_t count_ipv6 = 0;
+size_t count_ipv4 = 0;
 int action = -1;
 int pid_file_fd = -1;
 int rv = EXIT_FAILURE;
 int custom_lease_file_len = 0;
 bool add = false;
+bool 

Re: [libvirt] [PATCH V2 2/3] add error report for virMutexInit virRWLockInit and virCondInit

2014-07-21 Thread Jincheng Miao
- Original Message -
 On Mon, Jul 21, 2014 at 06:13:36PM +0800, Jincheng Miao wrote:
  Implement vir{Mutex,RWLock,Cond}InitInternal functions which have
  related error report when failure, and vir{Mutex,RWLock,Cond}Init
  as macros. So that the caller no longer to print error message
  explicitly.
  
  Signed-off-by: Jincheng Miao jm...@redhat.com
  ---
   src/libvirt_private.syms |  7 +++---
   src/util/virthread.c | 56
   +---
   src/util/virthread.h | 25 +
   3 files changed, 49 insertions(+), 39 deletions(-)
  
 
   
  +#define VIR_THREAD_ERR_EXIT(str) do {   \
  +errno = ret;\
  +virReportSystemErrorFull(VIR_FROM_NONE, errno,  \
  + filename, funcname, linenr,\
  + %s, _(str)); \
  +return -1;  \
  +} while (0)
 
 [snip]
 
  -int virCondInit(virCondPtr cond)
  +int virCondInitInternal(virCondPtr cond, const char *filename,
  +const char *funcname, size_t linenr)
   {
  -int ret;
  -if ((ret = pthread_cond_init(cond-cond, NULL)) != 0) {
  -errno = ret;
  -return -1;
  -}
  +int ret = pthread_cond_init(cond-cond, NULL);
  +if (ret != 0)
  +VIR_THREAD_ERR_EXIT(unable to init Condition);
  +
   return 0;
   }
 
 [snip]
 
  -int virCondInit(virCondPtr cond) ATTRIBUTE_RETURN_CHECK;
  +int virCondInitInternal(virCondPtr cond, const char *filename,
  +const char *funcname, size_t linenr)
  +ATTRIBUTE_RETURN_CHECK;
  +# define virCondInit(cond)  \
  +virCondInitInternal(cond, __FILE__, __FUNCTION__, __LINE__)
  +
 
 I can see what you're trying todo here by passing in __FILE__,
 __FUNCTION__, __LINE__ through from the calling site, but I don't
 really think this is beneficial and is not the way we deal with
 error reporting in any other similar helper APIs. IMHO just
 remove all this passing around of source location and let it do
 the default thing. In fact the default behaviour is probably
 better since if we want to search for any thread related error
 messages, we can query the journald for the virthread.c file
 directly.

OK, it's fine to drop them, and thanks for your review.

 
 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] numatune: finish the split from domain_conf and remove all dependencies

2014-07-21 Thread Martin Kletzander
This patch adds back the virDomainDef typedef into domain_conf and
makes all the numatune_conf functions independent of any virDomainDef
definitions.

Signed-off-by: Martin Kletzander mklet...@redhat.com
---
 src/conf/domain_conf.c   |  9 +-
 src/conf/domain_conf.h   |  2 ++
 src/conf/numatune_conf.c | 78 +---
 src/conf/numatune_conf.h | 23 +++---
 src/lxc/lxc_native.c |  8 +++--
 src/qemu/qemu_driver.c   | 10 +--
 6 files changed, 75 insertions(+), 55 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1e27165..9f20a3a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11809,9 +11809,16 @@ virDomainDefParseXML(xmlDocPtr xml,
 }
 }

-if (virDomainNumatuneParseXML(def, ctxt)  0)
+if (virDomainNumatuneParseXML(def-numatune,
+  def-placement_mode ==
+  VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC,
+  def-cpu ? def-cpu-ncells : 0,
+  ctxt)  0)
 goto error;

+if (virDomainNumatuneHasPlacementAuto(def-numatune)  !def-cpumask)
+def-placement_mode = VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO;
+
 if ((n = virXPathNodeSet(./resource, ctxt, nodes))  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
%s, _(cannot extract resource nodes));
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index cd3293b..1429568 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1853,6 +1853,8 @@ struct _virDomainResourceDef {
  * NB: if adding to this struct, virDomainDefCheckABIStability
  * may well need an update
  */
+typedef struct _virDomainDef virDomainDef;
+typedef virDomainDef *virDomainDefPtr;
 struct _virDomainDef {
 int virtType;
 int id;
diff --git a/src/conf/numatune_conf.c b/src/conf/numatune_conf.c
index 82418aa..48d1d04 100644
--- a/src/conf/numatune_conf.c
+++ b/src/conf/numatune_conf.c
@@ -76,13 +76,15 @@ virDomainNumatuneNodeSpecified(virDomainNumatunePtr 
numatune,
 }

 static int
-virDomainNumatuneNodeParseXML(virDomainDefPtr def,
+virDomainNumatuneNodeParseXML(virDomainNumatunePtr *numatunePtr,
+  size_t ncells,
   xmlXPathContextPtr ctxt)
 {
 char *tmp = NULL;
 int n = 0;;
 int ret = -1;
 size_t i = 0;
+virDomainNumatunePtr numatune = *numatunePtr;
 xmlNodePtr *nodes = NULL;

 if ((n = virXPathNodeSet(./numatune/memnode, ctxt, nodes))  0) {
@@ -94,29 +96,31 @@ virDomainNumatuneNodeParseXML(virDomainDefPtr def,
 if (!n)
 return 0;

-if (def-numatune  def-numatune-memory.specified 
-def-numatune-memory.placement == VIR_DOMAIN_NUMATUNE_PLACEMENT_AUTO) 
{
+if (numatune  numatune-memory.specified 
+numatune-memory.placement == VIR_DOMAIN_NUMATUNE_PLACEMENT_AUTO) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
_(Per-node binding is not compatible with 
  automatic NUMA placement.));
 goto cleanup;
 }

-if (!def-cpu || !def-cpu-ncells) {
+if (!ncells) {
 virReportError(VIR_ERR_XML_ERROR, %s,
_(Element 'memnode' is invalid without 
  any guest NUMA cells));
 goto cleanup;
 }

-if (!def-numatune  VIR_ALLOC(def-numatune)  0)
+if (!numatune  VIR_ALLOC(numatune)  0)
 goto cleanup;

-VIR_FREE(def-numatune-mem_nodes);
-if (VIR_ALLOC_N(def-numatune-mem_nodes, def-cpu-ncells)  0)
+*numatunePtr = numatune;
+
+VIR_FREE(numatune-mem_nodes);
+if (VIR_ALLOC_N(numatune-mem_nodes, ncells)  0)
 goto cleanup;

-def-numatune-nmem_nodes = def-cpu-ncells;
+numatune-nmem_nodes = ncells;

 for (i = 0; i  n; i++) {
 int mode = 0;
@@ -139,14 +143,14 @@ virDomainNumatuneNodeParseXML(virDomainDefPtr def,
 }
 VIR_FREE(tmp);

-if (cellid = def-numatune-nmem_nodes) {
+if (cellid = numatune-nmem_nodes) {
 virReportError(VIR_ERR_XML_ERROR, %s,
_(Argument 'cellid' in memnode element must 
  correspond to existing guest's NUMA cell));
 goto cleanup;
 }

-mem_node = def-numatune-mem_nodes[cellid];
+mem_node = numatune-mem_nodes[cellid];

 if (mem_node-nodeset) {
 virReportError(VIR_ERR_XML_ERROR,
@@ -189,7 +193,9 @@ virDomainNumatuneNodeParseXML(virDomainDefPtr def,
 }

 int
-virDomainNumatuneParseXML(virDomainDefPtr def,
+virDomainNumatuneParseXML(virDomainNumatunePtr *numatunePtr,
+  bool placement_static,
+  size_t ncells,
   xmlXPathContextPtr ctxt)
 {
 char *tmp = NULL;
@@ -212,23 +218,25 @@ virDomainNumatuneParseXML(virDomainDefPtr def,

 node = 

[libvirt] [PATCH 1/2] blockcommit: track job type in xml

2014-07-21 Thread Eric Blake
A future patch is going to wire up qemu active block commit jobs;
but as they have similar events and are canceled/pivoted in the
same way as block copy jobs, it is easiest to track all bookkeeping
for the commit job by reusing the mirror element.  This patch
adds domain XML to track which job was responsible for creating a
mirroring situation, and adds a job='copy' attribute to all
existing uses of mirror.  Along the way, it also massages the
qemu monitor backend to read the new field in order to generate
the correct type of libvirt job (even though it requires a
future patch to actually cause a qemu event that can be reported
as an active commit).

* docs/schemas/domaincommon.rng: Enhance schema.
* docs/formatdomain.html.in: Document it.
* src/conf/domain_conf.h (_virDomainDiskDef): Add a field.
* src/conf/domain_conf.c (virDomainBlockJobType): String conversion.
(virDomainDiskDefParseXML): Parse job type.
(virDomainDiskDefFormat): Output job type.
* src/qemu/qemu_process.c (qemuProcessHandleBlockJob): Distinguish
active from regular commit.
* src/qemu/qemu_driver.c (qemuDomainBlockCopy): Set job type.
(qemuDomainBlockPivot, qemuDomainBlockJobImpl): Clean up job type
on completion.
* tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml:
Update tests.
* tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml: Likewise.
* tests/qemuxml2argvdata/qemuxml2argv-disk-active-commit.xml: New
file.
* tests/qemuxml2xmltest.c (mymain): Drive new test.

Signed-off-by: Eric Blake ebl...@redhat.com
---
 docs/formatdomain.html.in  | 21 ++--
 docs/schemas/domaincommon.rng  | 13 
 src/conf/domain_conf.c | 33 ++-
 src/conf/domain_conf.h |  1 +
 src/qemu/qemu_driver.c |  3 ++
 src/qemu/qemu_process.c| 18 +++
 .../qemuxml2argv-disk-active-commit.xml| 37 ++
 .../qemuxml2argvdata/qemuxml2argv-disk-mirror.xml  |  4 +--
 .../qemuxml2xmlout-disk-mirror-old.xml |  4 +--
 tests/qemuxml2xmltest.c|  1 +
 10 files changed, 114 insertions(+), 21 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-active-commit.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 8950959..7593b55 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1898,16 +1898,19 @@
   /dd
   dtcodemirror/code/dt
   dd
-This element is present if the hypervisor has started a block
-copy operation (via the codevirDomainBlockRebase/code
-API), where the mirror location in the codesource/code
-sub-element will eventually have the same contents as the
-source, and with the file format in the
+This element is present if the hypervisor has started a
+long-running block job operation, where the mirror location in
+the codesource/code sub-element will eventually have the
+same contents as the source, and with the file format in the
 sub-element codeformat/code (which might differ from the
-format of the source).  The details of the codesource/code
-sub-element are determined by the codetype/code attribute
-of the mirror, similar to what is done for the
-overall codedisk/code device element. If
+format of the source).  The codejob/code attribute
+mentions which API started the operation (copy for
+the codevirDomainBlockRebase/code API, or active-commit
+for the codevirDomainBlockCommit/code
+API), span class=sincesince 1.2.7/span.  The details
+of the codesource/code sub-element are determined by
+the codetype/code attribute of the mirror, similar to what
+is done for the overall codedisk/code device element. If
 attribute codeready/code is present, then it is known the
 disk is ready to pivot; otherwise, the disk is probably still
 copying.  For now, this element only valid in output; it is
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 835bd3c..231c743 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4262,6 +4262,13 @@
 /attribute
   /optional
   optional
+attribute name='job'
+  choice
+valuecopy/value
+  /choice
+/attribute
+  /optional
+  optional
 interleave
   ref name='diskSourceFile'/
   optional
@@ -4271,6 +4278,12 @@
   /optional
 /group
 group !-- preferred format --
+  attribute name='job'
+choice
+  valuecopy/value
+  valueactive-commit/value
+/choice
+  /attribute
   interleave
 ref name=diskSource/
   

[libvirt] [PATCH 2/2] blockjob: properly track blockcopy xml changes on disk

2014-07-21 Thread Eric Blake
We were not directly saving the domain XML to file after starting
or finishing a blockcopy.  Without the startup write, a libvirtd
restart in the middle of a copy job would forget that the job was
underway.  Then at pivot, we were indirectly writing new XML in
reaction to events that occur as we stop and restart the guest CPUs.
But there was a race: since pivot is an async action, it is possible
that the guest is restarted before the pivot completes, so if XML
changes during the event, that change was not written.  The original
blockcopy code cleared out the mirror element prior to restarting
the CPUs, but this is also a race, observed if a user does an async
pivot and a dumpxml before the event occurs.  Furthermore, this race
will interfere with active commit, because that code relies on the
mirror element at the time of the qemu event to determine whether
to inform the user of a normal commit or an active commit.

Fix things by saving state any time we modify live XML, and by
delaying XML modifications until after the event completes.  We
still need a solution for the case of libvirtd restarting in between
requesting qemu to do the pivot and the actual event (that is, if
libvirtd misses the event, but learns the job is complete thanks to
a block query, then the updated state still needs to be updated in
live XML), but that will be a later patch, in part because we want
to start taking advantage of newer qemu's ability to keep the job
around after completion rather than the current usage where the job
disappears both on error and on success.

* src/qemu/qemu_driver.c (qemuDomainBlockCopy): Track XML change
on disk.
(qemuDomainBlockPivot): Move post-pivot XML rewrites...
* src/qemu/qemu_process.c (qemuProcessHandleBlockJob): ...here,
and expand to cover case of persistent vm.

Signed-off-by: Eric Blake ebl...@redhat.com
---
 src/qemu/qemu_driver.c  | 46 ++---
 src/qemu/qemu_process.c | 69 +++--
 2 files changed, 86 insertions(+), 29 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 368e112..a5eaead 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14843,39 +14841,41 @@ qemuDomainBlockPivot(virConnectPtr conn,
  virSecurityManagerSetDiskLabel(driver-securityManager, vm-def, 
disk)  0))
 goto cleanup;

-/* Attempt the pivot.  */
+/* Attempt the pivot.  We will update the domain later when qemu
+ * emits an event, telling us if we succeeded or failed.
+ * XXX On libvirtd restarts, if we missed the qemu event, we need
+ * to double check what state qemu is in.
+ * XXX We should be using qemu's rerror flag to make sure the job
+ * remains alive until we know it's final state.
+ * XXX If the abort command is synchronous but the qemu event is
+ * that the pivot failed, we need to reflect that failure into the
+ * overall return value.  */
 qemuDomainObjEnterMonitor(driver, vm);
 ret = qemuMonitorDrivePivot(priv-mon, device, disk-mirror-path, format);
 qemuDomainObjExitMonitor(driver, vm);

-if (ret == 0) {
-/* XXX We want to revoke security labels and disk lease, as
- * well as audit that revocation, before dropping the original
- * source.  But it gets tricky if both source and mirror share
- * common backing files (we want to only revoke the non-shared
- * portion of the chain, and is made more difficult by the
- * fact that we aren't tracking the full chain ourselves; so
- * for now, we leak the access to the original.  */
-virStorageSourceFree(oldsrc);
-oldsrc = NULL;
-} else {
+if (ret  0) {
 /* On failure, qemu abandons the mirror, and reverts back to
  * the source disk (RHEL 6.3 has a bug where the revert could
  * cause catastrophic failure in qemu, but we don't need to
  * worry about it here as it is not an upstream qemu problem.  */
 /* XXX should we be parsing the exact qemu error, or calling
  * 'query-block', to see what state we really got left in
- * before killing the mirroring job?  And just as on the
- * success case, there's security labeling to worry about.  */
+ * before killing the mirroring job?
+ * XXX We want to revoke security labels and disk lease, as
+ * well as audit that revocation, before dropping the original
+ * source.  But it gets tricky if both source and mirror share
+ * common backing files (we want to only revoke the non-shared
+ * portion of the chain); so for now, we leak the access to
+ * the original.  */
 virStorageSourceFree(disk-mirror);
-}

-disk-mirror = NULL;
-disk-mirroring = false;
-disk-mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN;
+disk-mirror = NULL;
+disk-mirroring = false;
+disk-mirrorJob =