Re: [libvirt] [BUG,RFC] directory traversal vulnerability / qemu: name→uuid

2011-09-08 Thread Philipp Hahn
Hello Eric,

On Wednesday 07 September 2011 16:02:51 Eric Blake wrote:
 On 09/07/2011 11:12 AM, Philipp Hahn wrote:
  I just tried the following command  with libvirt-0.9.5git:
  # virsh snapshot-create $VM /dev/stdin
  'domainsnapshotname../../../../../../etc/passwd/name/domainsnap
 shot'
 
  Luckily it adds a .xml suffix, but this still looks like a security
  problem to me, because you can overwrite any .xml-file with libvirt
  gibberish. Actually this was found by a user trying to create a snapshot
  with an embedded /, which didn't work, because the sub-directory didn't
  exist. I know SELinux can solve this, but I really would prefer the Qemu
  driver to reject such names.

 Qemu won't reject names with /, but I agree with your thought that
 libvirt needs to prevent such names, particularly since it creates
 several other file names (such as log files, managed save, snapshots,
 and even the monitor file) all based on the domain name.

For Qemu the name is just a C-string, but libvirt make the error to use those 
bits as something else, namely a UNIX/Windows/whatever path name, which has 
additional constraints. So if libvirt wants to use the name as a path, it 
must add an additional constraint on the naming to make it safe, or at lease 
use some escaping when translating the name to a path name.

   You are also missing:
 /var/log/libvirt/qemu/$VM.log

Yes, which is compilcated by logrotate replacing and renaming those files.

  Would it be possible and feasible to convert the Qemu driver to use the
  UUID instead for file and directory naming?

 Maybe, but I prefer seeing files by name rather than by UUID when
 browsing through the libvirt internal directories.  If we supported
 renaming, and properly altered the name of all affected files, then I
 see no reason to keep the files by name instead of uuid.

Yes, names are definitly nicer than UUIDs, but they make renaming harder (I 
hope nobody want's to change the UUID) and have the meta-character problem. 
With UUID we are sure, that they always consists of safe characters and have 
a finit length.

Sincerely
Philipp
-- 
Philipp Hahn   Open Source Software Engineer  h...@univention.de
Univention GmbHLinux for Your Businessfon: +49 421 22 232- 0
Mary-Somerville-Str.1  D-28359 Bremen fax: +49 421 22 232-99
   http://www.univention.de/

Treffen Sie Univention auf der ITBusiness vom 20. bis 22. September 2011
auf dem Gemeinschaftsstand der Open Source Business Alliance in Stuttgart in
Halle 3 Stand 3D27-7.


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

[libvirt] [PATCH v2 1/2] Add VIR_TYPED_PARAM_STRING

2011-09-08 Thread Hu Tao
---
 daemon/remote.c  |   15 +++
 include/libvirt/libvirt.h.in |4 +++-
 src/remote/remote_driver.c   |   15 +++
 src/remote/remote_protocol.x |2 ++
 src/remote_protocol-structs  |2 ++
 5 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 38bbb10..a9d0daa 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -613,6 +613,13 @@ remoteSerializeTypedParameters(virTypedParameterPtr params,
 case VIR_TYPED_PARAM_BOOLEAN:
 val[i].value.remote_typed_param_value_u.b = params[i].value.b;
 break;
+case VIR_TYPED_PARAM_STRING:
+val[i].value.remote_typed_param_value_u.s = 
strdup(params[i].value.s);
+if (val[i].value.remote_typed_param_value_u.s == NULL) {
+virReportOOMError();
+goto cleanup;
+}
+break;
 default:
 virNetError(VIR_ERR_RPC, _(unknown parameter type: %d),
 params[i].type);
@@ -691,6 +698,14 @@ remoteDeserializeTypedParameters(remote_typed_param 
*args_params_val,
 params[i].value.b =
 args_params_val[i].value.remote_typed_param_value_u.b;
 break;
+case VIR_TYPED_PARAM_STRING:
+params[i].value.s =
+strdup(args_params_val[i].value.remote_typed_param_value_u.s);
+if (params[i].value.s == NULL) {
+virReportOOMError();
+goto cleanup;
+}
+break;
 default:
 virNetError(VIR_ERR_INTERNAL_ERROR, _(unknown parameter type: 
%d),
 params[i].type);
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 5fa489e..e57241c 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -488,7 +488,8 @@ typedef enum {
 VIR_TYPED_PARAM_LLONG   = 3, /* long long case */
 VIR_TYPED_PARAM_ULLONG  = 4, /* unsigned long long case */
 VIR_TYPED_PARAM_DOUBLE  = 5, /* double case */
-VIR_TYPED_PARAM_BOOLEAN = 6  /* boolean(character) case */
+VIR_TYPED_PARAM_BOOLEAN = 6, /* boolean(character) case */
+VIR_TYPED_PARAM_STRING  = 7  /* string case */
 } virTypedParameterType;
 
 /**
@@ -519,6 +520,7 @@ struct _virTypedParameter {
 unsigned long long int ul;  /* type is ULLONG */
 double d;   /* type is DOUBLE */
 char b; /* type is BOOLEAN */
+char *s;/* type is STRING */
 } value; /* parameter value */
 };
 
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 9d34b7e..f4cdc2e 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1276,6 +1276,13 @@ remoteSerializeTypedParameters(virTypedParameterPtr 
params,
 case VIR_TYPED_PARAM_BOOLEAN:
 val[i].value.remote_typed_param_value_u.b = params[i].value.b;
 break;
+case VIR_TYPED_PARAM_STRING:
+val[i].value.remote_typed_param_value_u.s = 
strdup(params[i].value.s);
+if (val[i].value.remote_typed_param_value_u.s == NULL) {
+virReportOOMError();
+goto cleanup;
+}
+break;
 default:
 remoteError(VIR_ERR_RPC, _(unknown parameter type: %d),
 params[i].type);
@@ -1347,6 +1354,14 @@ remoteDeserializeTypedParameters(remote_typed_param 
*ret_params_val,
 params[i].value.b =
 ret_params_val[i].value.remote_typed_param_value_u.b;
 break;
+case VIR_TYPED_PARAM_STRING:
+params[i].value.s =
+strdup(ret_params_val[i].value.remote_typed_param_value_u.s);
+if (params[i].value.s == NULL) {
+virReportOOMError();
+goto cleanup;
+}
+break;
 default:
 remoteError(VIR_ERR_RPC, _(unknown parameter type: %d),
 params[i].type);
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 4ec1c57..93e6374 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -317,6 +317,8 @@ union remote_typed_param_value switch (int type) {
  double d;
  case VIR_TYPED_PARAM_BOOLEAN:
  int b;
+ case VIR_TYPED_PARAM_STRING:
+ remote_nonnull_string s;
 };
 
 struct remote_typed_param {
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 27178da..3c88258 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -6,6 +6,7 @@ enum {
 VIR_TYPED_PARAM_ULLONG = 4,
 VIR_TYPED_PARAM_DOUBLE = 5,
 VIR_TYPED_PARAM_BOOLEAN = 6,
+VIR_TYPED_PARAM_STRING = 7,
 };
 struct remote_nonnull_domain {
 remote_nonnull_string  name;
@@ -78,6 +79,7 @@ struct remote_typed_param_value {
 uint64_t   ul;
 

[libvirt] [PATCH v2 2/2] add interface for blkio.weight_device

2011-09-08 Thread Hu Tao
This patch adds a parameter --weight-device to virsh command
blkiotune for setting/getting blkio.weight_device.
---
 daemon/remote.c  |5 +
 include/libvirt/libvirt.h.in |9 ++
 src/conf/domain_conf.c   |  142 ++-
 src/conf/domain_conf.h   |   15 
 src/libvirt_private.syms |1 +
 src/qemu/qemu_cgroup.c   |   22 ++
 src/qemu/qemu_driver.c   |  170 +-
 src/util/cgroup.c|   33 
 src/util/cgroup.h|3 +
 tools/virsh.c|   31 
 tools/virsh.pod  |5 +-
 11 files changed, 430 insertions(+), 6 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index a9d0daa..ec91526 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -1503,6 +1503,7 @@ remoteDispatchDomainGetBlkioParameters(virNetServerPtr 
server ATTRIBUTE_UNUSED,
 int nparams = args-nparams;
 unsigned int flags;
 int rv = -1;
+int i;
 struct daemonClientPrivate *priv =
 virNetServerClientGetPrivateData(client);
 
@@ -1547,6 +1548,10 @@ success:
 cleanup:
 if (rv  0)
 virNetMessageSaveError(rerr);
+for (i = 0; i  nparams; i++) {
+if (params[i].type == VIR_TYPED_PARAM_STRING)
+VIR_FREE(params[i].value.s);
+}
 VIR_FREE(params);
 if (dom)
 virDomainFree(dom);
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index e57241c..c65d8f7 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1137,6 +1137,15 @@ char *  
virDomainGetSchedulerType(virDomainPtr domain,
 
 #define VIR_DOMAIN_BLKIO_WEIGHT weight
 
+/**
+ * VIR_DOMAIN_BLKIO_WEIGHT_DEVICE:
+ *
+ * Macro for the blkio tunable weight_device: it represents the
+ * per device weight.
+ */
+
+#define VIR_DOMAIN_BLKIO_WEIGHT_DEVICE weight_device
+
 /* Set Blkio tunables for the domain*/
 int virDomainSetBlkioParameters(virDomainPtr domain,
 virTypedParameterPtr params,
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 74f8d6a..d10e30c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -565,6 +565,108 @@ VIR_ENUM_IMPL(virDomainNumatuneMemMode, 
VIR_DOMAIN_NUMATUNE_MEM_LAST,
 #define VIR_DOMAIN_XML_WRITE_FLAGS  VIR_DOMAIN_XML_SECURE
 #define VIR_DOMAIN_XML_READ_FLAGS   VIR_DOMAIN_XML_INACTIVE
 
+/**
+ * virBlkioWeightDeviceToStr:
+ *
+ * This function returns a string representing device weights that is
+ * suitable for writing to /cgroup/blkio/blkio.weight_device, given
+ * a list of weight devices.
+ */
+int virBlkioWeightDeviceToStr(virBlkioWeightDevicePtr weightdevices,
+  int ndevices,
+  char **result)
+{
+int len = 0;
+int ret = -1;
+int i, j;
+char **weight_devices;
+char *str;
+
+if (VIR_ALLOC_N(weight_devices, ndevices)  0) {
+goto fail_nomem1;
+}
+for (i = 0; i  ndevices; i++) {
+int tmp;
+tmp = virAsprintf(weight_devices[i], %d:%d %d,
+  weightdevices[i].major,
+  weightdevices[i].minor,
+  weightdevices[i].weight);
+if (tmp  0) {
+goto fail_nomem2;
+}
+len += tmp + 1; /* 1 for '\n' and the trailing '\0' */
+}
+
+if (VIR_ALLOC_N(str, len)  0) {
+goto fail_nomem2;
+}
+for (i = 0; i  ndevices; i++) {
+strcat(str, weight_devices[i]);
+strcat(str, \n);
+}
+str[len-1] = '\0';
+
+*result = str;
+
+ret = 0;
+
+fail_nomem2:
+for (j = 0; j  i; j++)
+VIR_FREE(weight_devices[i]);
+VIR_FREE(weight_devices);
+fail_nomem1:
+if (ret != 0)
+virReportOOMError();
+return ret;
+}
+
+/**
+ * virDomainBlkioWeightDeviceParseXML
+ *
+ * this function parses a XML node:
+ *
+ *   device
+ * majormajor/major
+ * minorminor/minor
+ * weightweight/weight
+ *   /device
+ *
+ * and fills a virBlkioWeightDevice struct.
+ */
+static int virDomainBlkioWeightDeviceParseXML(xmlNodePtr root,
+  virBlkioWeightDevicePtr dw)
+{
+char *c;
+xmlNodePtr node;
+
+if (!dw)
+return -1;
+
+node = root-children;
+while (node) {
+if (node-type == XML_ELEMENT_NODE) {
+if (xmlStrEqual(node-name, BAD_CAST major)) {
+c = (char *)xmlNodeGetContent(node);
+dw-major = atoi(c);
+VIR_FREE(c);
+} else if (xmlStrEqual(node-name, BAD_CAST minor)) {
+c = (char *)xmlNodeGetContent(node);
+dw-minor = atoi(c);
+VIR_FREE(c);
+} else if (xmlStrEqual(node-name, BAD_CAST weight)) {
+c = (char *)xmlNodeGetContent(node);
+dw-weight = atoi(c);
+VIR_FREE(c);
+}
+}
+   

[libvirt] [PATCH v2 0/2] add blkio.weight_device support

2011-09-08 Thread Hu Tao
This series adds support for blkio.weight_device.

changes from v1:

- update remote_protocol-structs to make `make check` pass
- fix some memleaks
- compared the sizes of remote_typed_param before and after
  patch 1 using pdwtags, doesn't change
- libvirtd(before patch) returns an error message
error: Unable to decode message payload
  if connect to it and send a remote_typed_param(after patch)
  via virsh(after patch)

Hu Tao (2):
  Add VIR_TYPED_PARAM_STRING
  add interface for blkio.weight_device

 daemon/remote.c  |   20 +
 include/libvirt/libvirt.h.in |   13 +++-
 src/conf/domain_conf.c   |  142 ++-
 src/conf/domain_conf.h   |   15 
 src/libvirt_private.syms |1 +
 src/qemu/qemu_cgroup.c   |   22 ++
 src/qemu/qemu_driver.c   |  170 +-
 src/remote/remote_driver.c   |   15 
 src/remote/remote_protocol.x |2 +
 src/remote_protocol-structs  |2 +
 src/util/cgroup.c|   33 
 src/util/cgroup.h|3 +
 tools/virsh.c|   31 
 tools/virsh.pod  |5 +-
 14 files changed, 467 insertions(+), 7 deletions(-)

-- 
1.7.3.1

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


[libvirt] Start of freeze for libvirt-0.9.5 and availability of rc1

2011-09-08 Thread Daniel Veillard
 With a bit of delay, we are entering the freeze for libvirt-0.9.5 .
We may make an exception for the last couple of patches from Hu to
add string to typed parameters and the extra associated patch, as
well as bug fixes too of course !

I have made a release candidate 1 tarball (and associated rpms) at
  ftp://libvirt.org/libvirt/libvirt-0.9.5-rc1.tar.gz

This seems to pass my minimal tests without problems, but please
give it a try too and report problems,

  I think I will make an rc2 next Monday (or earlier) and then try to
make the release around Wednesday next week

  thanks in advance,

Daniel

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

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


[libvirt] [PATCH] qemu: Search for disk in qemuDomainGetBlockInfo

2011-09-08 Thread Michal Privoznik
The commit 89b6284fd94ce5b13ee6b002f9167f5d9074aa7a caused regression.
Although we now allow users to input e.g. 'hda' instead of whole path,
we still need to search for appropriate disk in VM definition.
---
 src/qemu/qemu_driver.c |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1925ba5..fec4eeb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7755,6 +7755,7 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
 virStorageFileMetadata *meta = NULL;
 virDomainDiskDefPtr disk = NULL;
 struct stat sb;
+int i;
 int format;
 const char *actual;
 
@@ -7785,6 +7786,21 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
 }
 path = actual;
 
+/* Check the path belongs to this domain. */
+for (i = 0 ; i  vm-def-ndisks ; i++) {
+if (vm-def-disks[i]-src != NULL 
+STREQ (vm-def-disks[i]-src, path)) {
+disk = vm-def-disks[i];
+break;
+}
+}
+
+if (!disk) {
+qemuReportError(VIR_ERR_INVALID_ARG,
+_(invalid path %s not assigned to domain), path);
+goto cleanup;
+}
+
 /* The path is correct, now try to open it and get its size. */
 fd = open(path, O_RDONLY);
 if (fd == -1) {
-- 
1.7.3.4

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


Re: [libvirt] [Libvirt-announce] Start of freeze for libvirt-0.9.5 and availability of rc1

2011-09-08 Thread Justin Clift
On 08/09/2011, at 5:29 PM, Daniel Veillard wrote:
 With a bit of delay, we are entering the freeze for libvirt-0.9.5 .
 We may make an exception for the last couple of patches from Hu to
 add string to typed parameters and the extra associated patch, as
 well as bug fixes too of course !
 
 I have made a release candidate 1 tarball (and associated rpms) at
  ftp://libvirt.org/libvirt/libvirt-0.9.5-rc1.tar.gz
 
 This seems to pass my minimal tests without problems, but please
 give it a try too and report problems,


Just tried it on OSX 10.7.1 64-bit.  It barfs with the following:

CC libvirt_driver_storage_la-storage_backend_scsi.lo
CC libvirt_net_rpc_server_la-virnetserverprogram.lo
  storage/storage_backend_fs.c:616: error: expected '=', ',', ';', 'asm' or 
'__attribute__' before 'virStorageBackendFileSystemProbe'
  storage/storage_backend_fs.c: In function 'virStorageBackendExecuteMKFS':
  storage/storage_backend_fs.c:635: error: 'MKFS' undeclared (first use in this 
function)
  storage/storage_backend_fs.c:635: error: (Each undeclared identifier is 
reported only once
  storage/storage_backend_fs.c:635: error: for each function it appears in.)
  storage/storage_backend_fs.c: In function 'virStorageBackendMakeFileSystem':
  storage/storage_backend_fs.c:681: error: 'FILESYSTEM_PROBE_NOT_FOUND' 
undeclared (first use in this function)
  make[3]: *** [libvirt_driver_storage_la-storage_backend_fs.lo] Error 1
  make[3]: *** Waiting for unfinished jobs
  make[2]: *** [all] Error 2
  make[1]: *** [all-recursive] Error 1
  make: *** [all] Error 2

Does anyone have time to look into it?

If it's helpful, the Mac Mini in the Westford RH lab was recently
upgraded to OSX 10.7, so could be used for testing/debugging if
someone wants. :)

NOTE - I'm not subscribed to libvir-list, so please CC me on responses. :)

Regards and best wishes,

Justin Clift

--
Aeolus Community Manager
http://www.aeolusproject.org


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


Re: [libvirt] [PATCH] qemu: Search for disk in qemuDomainGetBlockInfo

2011-09-08 Thread Eric Blake

On 09/08/2011 09:55 AM, Michal Privoznik wrote:

The commit 89b6284fd94ce5b13ee6b002f9167f5d9074aa7a caused regression.
Although we now allow users to input e.g. 'hda' instead of whole path,
we still need to search for appropriate disk in VM definition.
---
  src/qemu/qemu_driver.c |   16 
  1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1925ba5..fec4eeb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7755,6 +7755,7 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
  virStorageFileMetadata *meta = NULL;
  virDomainDiskDefPtr disk = NULL;
  struct stat sb;
+int i;
  int format;
  const char *actual;

@@ -7785,6 +7786,21 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
  }
  path = actual;

+/* Check the path belongs to this domain. */
+for (i = 0 ; i  vm-def-ndisks ; i++) {
+if (vm-def-disks[i]-src != NULL
+STREQ (vm-def-disks[i]-src, path)) {
+disk = vm-def-disks[i];
+break;
+}
+}


NACK.  This is open-coding the effects of virDomainDiskIndexByName(). 
Instead, we should be doing something like:


int i = virDomainDiskIndexByName(vm-def, path, false);
if (i  0) error;
disk = vm-def-disks[i];

instead of virDomainDiskPathByName().

--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


[libvirt] [PATCHv2] blockinfo: fix qemu regression in handling disk name

2011-09-08 Thread Eric Blake
Regression introduced in commit 89b6284fd, due to an incorrect
conversion to the new means of converting disk names back to
the correct object.

* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo): Avoid NULL deref.
---
 src/qemu/qemu_driver.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1925ba5..f73270f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7755,8 +7755,8 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
 virStorageFileMetadata *meta = NULL;
 virDomainDiskDefPtr disk = NULL;
 struct stat sb;
+int i;
 int format;
-const char *actual;

 virCheckFlags(0, -1);

@@ -7778,12 +7778,12 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
 }

 /* Check the path belongs to this domain. */
-if (!(actual = virDomainDiskPathByName(vm-def, path))) {
+if ((i = virDomainDiskIndexByName(vm-def, path, false))  0) {
 qemuReportError(VIR_ERR_INVALID_ARG,
 _(invalid path %s not assigned to domain), path);
 goto cleanup;
 }
-path = actual;
+disk = vm-def-disks[i];

 /* The path is correct, now try to open it and get its size. */
 fd = open(path, O_RDONLY);
-- 
1.7.4.4

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


Re: [libvirt] [PATCHv2] blockinfo: fix qemu regression in handling disk name

2011-09-08 Thread Michal Privoznik
On 08.09.2011 11:12, Eric Blake wrote:
 Regression introduced in commit 89b6284fd, due to an incorrect
 conversion to the new means of converting disk names back to
 the correct object.
 
 * src/qemu/qemu_driver.c (qemuDomainGetBlockInfo): Avoid NULL deref.
 ---
  src/qemu/qemu_driver.c |6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index 1925ba5..f73270f 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -7755,8 +7755,8 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
  virStorageFileMetadata *meta = NULL;
  virDomainDiskDefPtr disk = NULL;
  struct stat sb;
 +int i;
  int format;
 -const char *actual;
 
  virCheckFlags(0, -1);
 
 @@ -7778,12 +7778,12 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
  }
 
  /* Check the path belongs to this domain. */
 -if (!(actual = virDomainDiskPathByName(vm-def, path))) {
 +if ((i = virDomainDiskIndexByName(vm-def, path, false))  0) {
  qemuReportError(VIR_ERR_INVALID_ARG,
  _(invalid path %s not assigned to domain), path);
  goto cleanup;
  }
 -path = actual;
 +disk = vm-def-disks[i];
 
  /* The path is correct, now try to open it and get its size. */
  fd = open(path, O_RDONLY);

In fact, we need to update path as well, beacuse we use it later (as can
be seen in context. but that is not the only place).

so ACK with this nit fixed.

Michal

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


Re: [libvirt] [PATCHv2] blockinfo: fix qemu regression in handling disk name

2011-09-08 Thread Eric Blake

On 09/08/2011 10:29 AM, Michal Privoznik wrote:

On 08.09.2011 11:12, Eric Blake wrote:

Regression introduced in commit 89b6284fd, due to an incorrect
conversion to the new means of converting disk names back to
the correct object.

-path = actual;
+disk = vm-def-disks[i];

  /* The path is correct, now try to open it and get its size. */
  fd = open(path, O_RDONLY);


In fact, we need to update path as well, beacuse we use it later (as can
be seen in context. but that is not the only place).


Ouch; you're right.  I'm squashing this in:

diff --git i/src/qemu/qemu_driver.c w/src/qemu/qemu_driver.c
index f73270f..b94d1c4 100644
--- i/src/qemu/qemu_driver.c
+++ w/src/qemu/qemu_driver.c
@@ -7784,6 +7784,13 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
 goto cleanup;
 }
 disk = vm-def-disks[i];
+if (!disk-src) {
+qemuReportError(VIR_ERR_INVALID_ARG,
+_(disk %s does not currently have a source 
assigned),

+path);
+goto cleanup;
+}
+path = disk-src;

 /* The path is correct, now try to open it and get its size. */
 fd = open(path, O_RDONLY);




so ACK with this nit fixed.


and pushing.

--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


Re: [libvirt] [PATCH] esx: Fix managed object lookup with optional occurrence

2011-09-08 Thread Matthias Bolte
2011/9/7 Eric Blake ebl...@redhat.com:
 On 09/06/2011 09:01 PM, Matthias Bolte wrote:

 Exit early if managed object is not found, instead of dereferencing
 a NULL pointer and triggering a segfault.
 ---
  src/esx/esx_vi.c |    8 +++-
  1 files changed, 7 insertions(+), 1 deletions(-)

 ACK.

Thanks, pushed.

-- 
Matthias Bolte
http://photron.blogspot.com

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

Re: [libvirt] [PATCH] virsh: fix typo in opts_send_key

2011-09-08 Thread Eric Blake

On 09/08/2011 04:11 AM, a...@redhat.com wrote:

From: Alex Jiaa...@redhat.com

* tools/virsh.c: millseconds should be milliseconds in opts_send_key.

Signed-off-by: Alex Jiaa...@redhat.com
---
  tools/virsh.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 0f00463..cf3e816 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -4301,7 +4301,7 @@ static const vshCmdOptDef opts_send_key[] = {
  {codeset, VSH_OT_STRING, VSH_OFLAG_REQ_OPT,
   N_(the codeset of keycodes, default:linux)},
  {holdtime, VSH_OT_INT, VSH_OFLAG_REQ_OPT,
- N_(the time (in millseconds) how long the keys will be held)},
+ N_(the time (in milliseconds) how long the keys will be held)},


ACK and pushed.

--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


Re: [libvirt] [PATCH] libxl: avoid a dereference of a null pointer

2011-09-08 Thread Eric Blake

On 09/06/2011 11:03 PM, Jim Fehlig wrote:

Alex Jia wrote:

Variable 'l_disk' initialized to a null pointer value, control jumps to 'case
VIR_DOMAIN_DISK_DEVICE_DISK and then taking false branch, Within the expansion
of the macro 'libxlError': Field access results in a dereference of a null
pointer (loaded from variable 'l_disk').

* src/libxl/libxl_driver.c: Field access results in a dereference of a null
   pointer (loaded from variable 'l_disk')



ACK.


Pushed.

--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


Re: [libvirt] [PATCH 2/2] rpc: avoid memory leak on virNetTLSContextValidCertificate

2011-09-08 Thread Eric Blake

On 09/04/2011 04:48 PM, Alex Jia wrote:

* src/rpc/virnettlscontext.c: fix memory leak on
   virNetTLSContextValidCertificate.

* Detected in valgrind run:




diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c
index e901b63..e6123f9 100644
--- a/src/rpc/virnettlscontext.c
+++ b/src/rpc/virnettlscontext.c
@@ -1050,6 +1050,7 @@ static int 
virNetTLSContextValidCertificate(virNetTLSContextPtr ctxt,
  goto authdeny;
  }
  }
+gnutls_x509_crt_deinit(cert);
  }


ACK and pushed.  This leak could kill a long-running libvirtd with lots 
of TLS clients repeatedly connecting, and the cleanup is similar to the 
cleanup done on failure paths.


--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


Re: [libvirt] [PATCH] Don't treat pci_system_init failure as fatal if no PCI bus is present

2011-09-08 Thread Eric Blake

On 09/06/2011 06:55 AM, Daniel Veillard wrote:

On Mon, Sep 05, 2011 at 09:29:06PM +0200, Soren Hansen wrote:

Xen PV domU's have no PCI bus. node_device_udev.c calls pci_system_init
which looks for /sys/bus/pci. If it does not find /sys/bus/pci (which it
won't in a Xen PV domU) it returns unsuccesfully (ENOENT), which libvirt
considers fatal. This makes libvirt unusable in this environment, even
though there are plenty of valid virtualisation options that work
there (LXC, UML, and QEmu spring to mind)

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

Signed-off-by: Soren Hansenso...@linux2go.dk
---
  src/node_device/node_device_udev.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/node_device/node_device_udev.c 
b/src/node_device/node_device_udev.c
index badf241..08ef856 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1620,7 +1620,7 @@ static int udevDeviceMonitorStartup(int privileged)
  /* Ignore failure as non-root; udev is not as helpful in that
   * situation, but a non-privileged user won't benefit much
   * from udev in the first place.  */
-if (privileged || errno != EACCES) {
+if (errno != ENOENT  (privileged  || errno != EACCES)) {
  char ebuf[256];
  VIR_ERROR(_(Failed to initialize libpciaccess: %s),
virStrerror(pciret, ebuf, sizeof ebuf));


   ACK,


Pushed.

--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


[libvirt] [PATCH 2/2] snapshot: use new API for less work

2011-09-08 Thread Eric Blake
This has the added benefit of making 'snapshot-create dom --no-metadata'
now able to tell you the name of the just-generated snapshot.

* tools/virsh.c (vshSnapshotCreate, cmdSnapshotCurrent): Don't get
XML just for name.
---
 tools/virsh.c |   41 +
 1 files changed, 9 insertions(+), 32 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index cf3e816..5e74947 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -12424,7 +12424,7 @@ vshSnapshotCreate(vshControl *ctl, virDomainPtr dom, 
const char *buffer,
 char *doc = NULL;
 xmlDocPtr xml = NULL;
 xmlXPathContextPtr ctxt = NULL;
-char *name = NULL;
+const char *name = NULL;

 snapshot = virDomainSnapshotCreateXML(dom, buffer, flags);

@@ -12459,21 +12459,9 @@ vshSnapshotCreate(vshControl *ctl, virDomainPtr dom, 
const char *buffer,
 goto cleanup;
 }

-if (flags  VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)
-doc = vshStrdup(ctl, buffer);
-else
-doc = virDomainSnapshotGetXMLDesc(snapshot, 0);
-if (!doc)
-goto cleanup;
-
-xml = virXMLParseStringCtxt(doc, domainsnapshot.xml, ctxt);
-if (!xml)
-goto cleanup;
-
-name = virXPathString(string(/domainsnapshot/name), ctxt);
+name = virDomainSnapshotGetName(snapshot);
 if (!name) {
-vshError(ctl, %s,
- _(Could not find 'name' element in domain snapshot XML));
+vshError(ctl, %s, _(Could not get snapshot name));
 goto cleanup;
 }

@@ -12485,7 +12473,6 @@ vshSnapshotCreate(vshControl *ctl, virDomainPtr dom, 
const char *buffer,
 ret = true;

 cleanup:
-VIR_FREE(name);
 xmlXPathFreeContext(ctxt);
 xmlFreeDoc(xml);
 if (snapshot)
@@ -12891,32 +12878,22 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
 if (current  0)
 goto cleanup;
 else if (current) {
-char *name = NULL;
+const char *name = NULL;

 if (!(snapshot = virDomainSnapshotCurrent(dom, 0)))
 goto cleanup;

-xml = virDomainSnapshotGetXMLDesc(snapshot, flags);
-if (!xml)
-goto cleanup;
-
 if (vshCommandOptBool(cmd, name)) {
-xmlDocPtr xmldoc = NULL;
-xmlXPathContextPtr ctxt = NULL;
-
-xmldoc = virXMLParseStringCtxt(xml, domainsnapshot.xml, ctxt);
-if (!xmldoc)
-goto cleanup;
-
-name = virXPathString(string(/domainsnapshot/name), ctxt);
-xmlXPathFreeContext(ctxt);
-xmlFreeDoc(xmldoc);
+name = virDomainSnapshotGetName(snapshot);
 if (!name)
 goto cleanup;
+} else {
+xml = virDomainSnapshotGetXMLDesc(snapshot, flags);
+if (!xml)
+goto cleanup;
 }

 vshPrint(ctl, %s, name ? name : xml);
-VIR_FREE(name);
 }

 ret = true;
-- 
1.7.4.4

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


[libvirt] [PATCH 0/2] snapshot: add getName API

2011-09-08 Thread Eric Blake
I know I've missed the 0.9.5 RC1 freeze, but think that this
new API is worth adding, if only because I noticed that
'virsh snapshot-create dom --no-metadata' currently creates
a snapshot with a generated name but then fails in attempting
to express that name to the user.

Eric Blake (2):
  snapshot: new APIs for inspecting snapshot object
  snapshot: use new API for less work

 include/libvirt/libvirt.h.in |4 ++
 src/libvirt.c|   73 ++
 src/libvirt_public.syms  |5 ++-
 tools/virsh.c|   41 +--
 4 files changed, 90 insertions(+), 33 deletions(-)

-- 
1.7.4.4

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


[libvirt] [PATCH 1/2] snapshot: new APIs for inspecting snapshot object

2011-09-08 Thread Eric Blake
These functions access internals of the opaque object, and do
not need any rpc counterpart.  It could be argued that we should
have provided these when snapshot objects were first introduced,
since all the other vir*Ptr objects have at least a GetName accessor.

* include/libvirt/libvirt.h.in (virDomainSnapshotGetName)
(virDomainSnapshotGetDomain, virDomainSnapshotGetConnect): Declare.
* src/libvirt.c (virDomainSnapshotGetName)
(virDomainSnapshotGetDomain, virDomainSnapshotGetConnect): New
functions.
* src/libvirt_public.syms: Export them.
---
 include/libvirt/libvirt.h.in |4 ++
 src/libvirt.c|   73 ++
 src/libvirt_public.syms  |5 ++-
 3 files changed, 81 insertions(+), 1 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 5fa489e..ea7b3fc 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -2656,6 +2656,10 @@ typedef struct _virDomainSnapshot virDomainSnapshot;
  */
 typedef virDomainSnapshot *virDomainSnapshotPtr;

+const char *virDomainSnapshotGetName(virDomainSnapshotPtr snapshot);
+virDomainPtr virDomainSnapshotGetDomain(virDomainSnapshotPtr snapshot);
+virConnectPtr virDomainSnapshotGetConnect(virDomainSnapshotPtr snapshot);
+
 typedef enum {
 VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE= (1  0), /* Restore or alter
   metadata */
diff --git a/src/libvirt.c b/src/libvirt.c
index dc082a6..c32c7a6 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -15665,6 +15665,79 @@ error:
 }

 /**
+ * virDomainSnapshotGetName:
+ * @snapshot: a snapshot object
+ *
+ * Get the public name for that snapshot
+ *
+ * Returns a pointer to the name or NULL, the string need not be deallocated
+ * as its lifetime will be the same as the snapshot object.
+ */
+const char *
+virDomainSnapshotGetName(virDomainSnapshotPtr snapshot)
+{
+VIR_DEBUG(snapshot=%p, snapshot);
+
+virResetLastError();
+
+if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) {
+virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT,
+  __FUNCTION__);
+virDispatchError(NULL);
+return NULL;
+}
+return snapshot-name;
+}
+
+/**
+ * virDomainSnapshotGetDomain:
+ * @snapshot: a snapshot object
+ *
+ * Get the domain that a snapshot was created for
+ *
+ * Returns the domain or NULL.
+ */
+virDomainPtr
+virDomainSnapshotGetDomain(virDomainSnapshotPtr snapshot)
+{
+VIR_DEBUG(snapshot=%p, snapshot);
+
+virResetLastError();
+
+if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) {
+virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT,
+  __FUNCTION__);
+virDispatchError(NULL);
+return NULL;
+}
+return snapshot-domain;
+}
+
+/**
+ * virDomainSnapshotGetConnect:
+ * @snapshot: a snapshot object
+ *
+ * Get the connection that owns the domain that a snapshot was created for
+ *
+ * Returns the connection or NULL.
+ */
+virConnectPtr
+virDomainSnapshotGetConnect(virDomainSnapshotPtr snapshot)
+{
+VIR_DEBUG(snapshot=%p, snapshot);
+
+virResetLastError();
+
+if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) {
+virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT,
+  __FUNCTION__);
+virDispatchError(NULL);
+return NULL;
+}
+return snapshot-domain-conn;
+}
+
+/**
  * virDomainSnapshotCreateXML:
  * @domain: a domain object
  * @xmlDesc: string containing an XML description of the domain
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index dc5a80b..8a6d55a 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -482,8 +482,11 @@ LIBVIRT_0.9.4 {

 LIBVIRT_0.9.5 {
 global:
-virDomainMigrateGetMaxSpeed;
 virDomainBlockStatsFlags;
+virDomainMigrateGetMaxSpeed;
+virDomainSnapshotGetConnect;
+virDomainSnapshotGetDomain;
+virDomainSnapshotGetName;
 } LIBVIRT_0.9.4;

 #  define new API here using predicted next version number 
-- 
1.7.4.4

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


[libvirt] [PATCH] maint: update to latest gnulib

2011-09-08 Thread Eric Blake
* .gnulib: Update to latest.
---

I'm not sure if any of these are essential for libvirt, but it's
probably nicer to pick up these fixes before the release than to
find out after the release that we wish we had them.

* .gnulib a6b16b6...da1717b (63):
   Doc about crypt functions.
   gc: Fix copyright header.
   pthread: Determine $(LIB_PTHREAD) correctly on OSF/1 5.1.
   openat: Work around compilation error with OSF/1 5.1 DTK cc.
   Revert last commit.
   openat: Work around compilation error with OSF/1 5.1 DTK cc.
   parse-datetime: document the newly accepted format
   autoupdate
   acl: Fix a test failure on newer Solaris 10 with ZFS.
   acl: Update for AIX = 5.3 with NFS.
   acl: Fix a test failure on AIX = 5.3 with NFS.
   acl: Fix a test failure on IRIX 6.5 with NFS.
   openat: port to AIX 7.1 with large files
   acl: Avoid errors on NonStop Kernel.
   acl: Clean up Solaris code.
   acl: Fix a bug with NFSv4 ACLs on Solaris 10 (newer version).
   acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
   copy-file: Try unit tests on more file systems.
   acl: Try unit tests on more file systems.
   acl: Remove unused code in last commit.
   acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
   openat: test for fstatat (..., 0) bug
   openat: test for fstatat (AT_FDCWD, ..., 0) bug
   avoid literal : in index entries
   Allow the user to override the choice of AR, ARFLAGS, RANLIB.
   Find 'ar' program that fits with --host argument.
   tests: init.sh: Support any non-GNU diff.
   tests: init.sh: work also with any non-GNU diff that supports -u
   strtoimax, strtoumax: Document problem on HP-UX 11.
   strtoumax: Avoid link error on OSF/1 with DTK cc.
   strtoimax: Avoid link error on OSF/1 with DTK cc.
   imaxdiv: Avoid link error on OSF/1 with DTK cc.
   imaxabs: Avoid link error on OSF/1 with DTK cc.
   Tests for module 'strtoumax'.
   Tests for module 'strtoimax'.
   Tests for module 'imaxdiv'.
   Tests for module 'imaxabs'.
   pthread: Determine $(LIB_PTHREAD) correctly on IRIX 6.5.
   * lib/fstatat.c: Include sys/types.h before sys/stat.h.
   openat: work around AIX 7.1 fstatat issue
   sys_select: Avoid a syntax error regarding timespec_t on IRIX 6.5.
   tests: avoid spurious assertion failure in test-float.c on ppc64
   maint: indent with spaces, not TABs
   test-parse-datetime.c: accommodate a relatively strict gcc warning
   parse-datetime: accept ISO 8601 date and time rep with T separator
   freopen: Documentation.
   freopen: Don't crash if the filename argument is NULL.
   openat: work around AIX 7.1 fstatat bug
   Avoid endless recursions if config.h includes some header files.
   autoupdate ylwrap
   autoupdate ylwrap
   autoupdate
   tmpdir: Use a good default directory on native Windows.
   autoupdate
   doc: fix typo in README-release
   fts: do not exhaust memory when processing million-entry directories
   maint: fts: move decl of `dp' down into while loop; split a long line
   fts: add/use new struct member, fts_dirp
   maint: fts: give __opendir2 a new parameter and rename
   maint: fts.c: remove __opendir2's now-unused parameter, oflag
   maint: fts.c: correct off-by-one indentation
   maint: fts.c: move __opendir2 #define up out of function body
   maint: fts.c: remove #if-0'd FTS_WHITEOUT code

 .gnulib |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/.gnulib b/.gnulib
index a6b16b6..da1717b 16
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit a6b16b69fe1cad695b270dd5bf3deb2850fc4dd1
+Subproject commit da1717b7f93b77469f980ea5e13178e4e9e7ae09
-- 
1.7.4.4

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


[libvirt] [PATCH] snapshot: fix regression with system checkpoints

2011-09-08 Thread Eric Blake
Regression introduced in commit d6f6b2d194c.

* src/conf/domain_conf.c (virDomainSnapshotDefParseString): Only
give error about no disk support when disk was found.
---
 src/conf/domain_conf.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 74f8d6a..560c773 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11622,7 +11622,7 @@ virDomainSnapshotDefParseString(const char *xmlStr,
 goto cleanup;
 }
 VIR_FREE(nodes);
-} else {
+} else if (i) {
 virDomainReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, %s,
  _(unable to handle disk requests in snapshot));
 goto cleanup;
-- 
1.7.4.4

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


Re: [libvirt] [PATCH] maint: update to latest gnulib

2011-09-08 Thread Daniel Veillard
On Thu, Sep 08, 2011 at 01:59:54PM +0100, Eric Blake wrote:
 * .gnulib: Update to latest.
 ---
 
 I'm not sure if any of these are essential for libvirt, but it's
 probably nicer to pick up these fixes before the release than to
 find out after the release that we wish we had them.

 yes definitely,

 ACK,

Daniel

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

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


Re: [libvirt] [PATCH 0/2] snapshot: add getName API

2011-09-08 Thread Daniel Veillard
On Thu, Sep 08, 2011 at 01:21:09PM +0100, Eric Blake wrote:
 I know I've missed the 0.9.5 RC1 freeze, but think that this
 new API is worth adding, if only because I noticed that
 'virsh snapshot-create dom --no-metadata' currently creates
 a snapshot with a generated name but then fails in attempting
 to express that name to the user.
 
 Eric Blake (2):
   snapshot: new APIs for inspecting snapshot object
   snapshot: use new API for less work
 
  include/libvirt/libvirt.h.in |4 ++
  src/libvirt.c|   73 
 ++
  src/libvirt_public.syms  |5 ++-
  tools/virsh.c|   41 +--
  4 files changed, 90 insertions(+), 33 deletions(-)

  Okay, the accessors make sense and the amount of changes
are minimal. The improvement of virsh.c make their need very clear

 ACK to the 2 patches

Daniel

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

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


Re: [libvirt] [PATCH] snapshot: fix regression with system checkpoints

2011-09-08 Thread Daniel Veillard
On Thu, Sep 08, 2011 at 02:17:10PM +0100, Eric Blake wrote:
 Regression introduced in commit d6f6b2d194c.
 
 * src/conf/domain_conf.c (virDomainSnapshotDefParseString): Only
 give error about no disk support when disk was found.
 ---
  src/conf/domain_conf.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
 index 74f8d6a..560c773 100644
 --- a/src/conf/domain_conf.c
 +++ b/src/conf/domain_conf.c
 @@ -11622,7 +11622,7 @@ virDomainSnapshotDefParseString(const char *xmlStr,
  goto cleanup;
  }
  VIR_FREE(nodes);
 -} else {
 +} else if (i) {
  virDomainReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, %s,
   _(unable to handle disk requests in 
 snapshot));
  goto cleanup;

  Okay, ACK,

Daniel

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

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


[libvirt] A question about create image for sheepdog

2011-09-08 Thread chang liu
Hi everyone:
I want to build a VM Manage System, and I use libvirt to create and delete
VM. But now I has used sheepdog as the disk, but I have to create sheepdog
image by hand. If I have a thousand of servers, how can I create the image?
I think if I can write a API for create the sheepdog image by call the
qemu-img or kvm-img? (My English is rather poor, please forgive me)
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2] xml: Change virtual file names of xml documents parsed in memory

2011-09-08 Thread Eric Blake

On 09/08/2011 02:25 PM, Peter Krempa wrote:

While parsing XML strings from memory, the previous convention in
libvirt was to set the virtual file name to domain.xml or something
similar. This could potentialy trick the user into looking for a file
named domain.xml on the disk in an attempt to fix the error.

This patch changes these filenames to something that can't be as easily
confused for a valid filename.

Examples of error messages:
---
Error while loading file from disk:

15:07:59.015: 527: error : catchXMLError:709 : /path/to/domain.xml:1: StartTag: 
invalid element name
domain type='kvm'
^

Error while parsing definintion in memory:

15:08:43.581: 525: error : catchXMLError:709 : (domain definition):2: error 
parsing attribute name
   namevm1/name
--^


I like it.  ACK, and worth pushing pre-release.

--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


Re: [libvirt] [PATCH] maint: update to latest gnulib

2011-09-08 Thread Eric Blake

On 09/08/2011 02:23 PM, Daniel Veillard wrote:

On Thu, Sep 08, 2011 at 01:59:54PM +0100, Eric Blake wrote:

* .gnulib: Update to latest.
---

I'm not sure if any of these are essential for libvirt, but it's
probably nicer to pick up these fixes before the release than to
find out after the release that we wish we had them.


  yes definitely,

  ACK,


Pushed.

--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


Re: [libvirt] [PATCH 0/2] snapshot: add getName API

2011-09-08 Thread Eric Blake

On 09/08/2011 02:22 PM, Daniel Veillard wrote:

On Thu, Sep 08, 2011 at 01:21:09PM +0100, Eric Blake wrote:

I know I've missed the 0.9.5 RC1 freeze, but think that this
new API is worth adding, if only because I noticed that
'virsh snapshot-create dom --no-metadata' currently creates
a snapshot with a generated name but then fails in attempting
to express that name to the user.

Eric Blake (2):
   snapshot: new APIs for inspecting snapshot object
   snapshot: use new API for less work

  include/libvirt/libvirt.h.in |4 ++
  src/libvirt.c|   73 ++
  src/libvirt_public.syms  |5 ++-
  tools/virsh.c|   41 +--
  4 files changed, 90 insertions(+), 33 deletions(-)


   Okay, the accessors make sense and the amount of changes
are minimal. The improvement of virsh.c make their need very clear

  ACK to the 2 patches


Pushed.

--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


Re: [libvirt] A question about create image for sheepdog

2011-09-08 Thread Alex Jia

On 09/08/2011 09:35 PM, chang liu wrote:

Hi everyone:
I want to build a VM Manage System, and I use libvirt to create and 
delete VM. But now I has used sheepdog as the disk, but I have to 
create sheepdog image by hand. If I have a thousand of servers, how 
can I create the image? I think if I can write a API for create the 
sheepdog image by call the qemu-img or kvm-img? (My English is rather 
poor, please forgive me)
Maybe, the 
virStorageBackendFSImageToolTypeToFunc/virStorageBackendCreateQemuImg 
API is what you want, you can find it from the following link:


http://libvirt.org/git/?p=libvirt.git;a=blob_plain;f=src/storage/storage_backend.c;hb=HEAD

Regards,
Alex



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

Re: [libvirt] [PATCH] snapshot: fix regression with system checkpoints

2011-09-08 Thread Eric Blake

On 09/08/2011 02:25 PM, Daniel Veillard wrote:

On Thu, Sep 08, 2011 at 02:17:10PM +0100, Eric Blake wrote:

Regression introduced in commit d6f6b2d194c.

* src/conf/domain_conf.c (virDomainSnapshotDefParseString): Only
give error about no disk support whendisk  was found.
---
  src/conf/domain_conf.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 74f8d6a..560c773 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11622,7 +11622,7 @@ virDomainSnapshotDefParseString(const char *xmlStr,
  goto cleanup;
  }
  VIR_FREE(nodes);
-} else {
+} else if (i) {
  virDomainReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, %s,
   _(unable to handle disk requests in snapshot));
  goto cleanup;


   Okay, ACK,


Thanks; pushed.

--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


Re: [libvirt] [PATCH v4] virsh: Add more human-friendly output of domblkstat command

2011-09-08 Thread Eric Blake

On 09/08/2011 03:11 PM, Peter Krempa wrote:

Users of virsh complain that output of the domblkstat command
is not intuitive enough. This patch adds explanation of fields
returned by this command to the help section for domblkstat and
the man page of virsh. Also a switch --human is added for
domblkstat that prints the fields with more descriptive
texts.

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

Changes to v3:
- Add units to duration values
- Add missing write doc/stranslation
- Add translation from new api names to legacy names used in previous
   versions in virsh


Nice, but still not quite ready.


+{desc, N_(Get device block stats for a running domain.\n\n
+Explanation of fields:\n
+  rd_req- count of read operations\n


That's a bit long for 'virsh help' when compared to other commands.  I'm 
not sure if it is sufficient to just list this in virsh.pod, but I'm 
also not opposed to keeping this part of the patch as-is.



+/* translations into a more human readable form */
+static const struct _domblkstat_translate domblkstat_human[] = {
+{ VIR_DOMAIN_BLOCK_STATS_READ_BYTES,N_(number of read bytes:  
) }, /* 0 */


You are correct that you have to use N_() here to initialize the array. 
 But...



+if (human) {
+/* human friendly output */
+vshPrint(ctl, N_(Device: %s\n), device);
+
+if (stats.rd_req= 0)
+vshPrint (ctl, %s %lld\n, domblkstat_human[1].to, 
stats.rd_req);


...that means down here, you have to translate things.  Also, your 
formatting is not typical (no space between function name and opening '('):


vshPrint(ctl, %s %lld\n, _(domblkstat_human[1].to), stats.rd_req);


@@ -1129,32 +1190,63 @@ cmdDomblkstat (vshControl *ctl, const vshCmd *cmd)
  }

  int i;
+
+/* set for prettier output */
+if (human) {
+vshPrint(ctl, N_(Device: %s\n), device);
+device = ;
+}
+
  /* XXX: The output sequence will be different. */


Can we fix this?  It would be nice if 0.9.4 and 0.9.5 output the initial 
fields in the same order when only the initial fields are available, and 
that only the presence of new fields causes the new ordering.



  for (i = 0; i  nparams; i++) {
+/* translate messages into a human readable form, if requested */
+field_name = NULL;
+
+if (human)
+for (j = 0; domblkstat_human[j].from != NULL; j++)
+if (STREQ(params[i].field, domblkstat_human[j].from)) {
+field_name = domblkstat_human[j].to;


Again, needs translation here, since the array could not be translated:

field_name = _(domblkstat_human[j].to);


+
+BExplanation of fields:
+  rd_req- count of read operations
+  rd_bytes  - count of read bytes
+  rd_total_times- total time read operations took (ns)
+  wr_req- count of write operations
+  wr_bytes  - count of written bytes
+  wr_total_times- total time write operations took (ns)
+  flush_operations  - count of flush operations
+  flush_total_times - total time flush operations took (ns)
+  errs  - error count


Maybe also mention that only the available fields are listed; in the 
case of older server or a hypervisor with less support, then unknown 
fields are omitted.


--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


[libvirt] [PATCH] Fix URL-escaping for domainDefine

2011-09-08 Thread Philipp Hahn
'+' in strings get translated to ' ' when editing domains.
While xenDaemonDomainCreateXML() did URL-escape the sexpr,
xenDaemonDomainDefineXML() did not.

Remove the explicit urlencode() in xenDaemonDomainCreateXML() and add
the direct encoding calls to xend_op_ext() because it calls xend_post()
which uses Content-Type: application/x-www-form-urlencoded. According
to http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1 this
requires all parameters to be url-encoded as specified in rfc1738.

Notice: virBufferAsprintf(..., %s=%s, ...) is again replaced by three
calls to virBufferURIEncodeString() and virBufferAddChar() because '='
is a reserved character, which would get escaped by
virBufferURIEncodeString(), which - by the way - escapes anything not
c_isalnum().

Signed-off-by: Philipp Hahn h...@univention.de
---
 src/xen/xend_internal.c |   62 
---
 1 files changed, 5 insertions(+), 57 deletions(-)

diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 8e21701..81ff325 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -487,7 +487,9 @@ xend_op_ext(virConnectPtr xend, const char *path, const char *key, va_list ap)
 while (k) {
 v = va_arg(ap, const char *);
 
-virBufferAsprintf(buf, %s=%s, k, v);
+virBufferURIEncodeString(buf, k);
+virBufferAddChar(buf, '=');
+virBufferURIEncodeString(buf, v);
 k = va_arg(ap, const char *);
 
 if (k)
@@ -599,47 +601,6 @@ sexpr_uuid(unsigned char *ptr, const struct sexpr *node, const char *path)
 return virUUIDParse(r, ptr);
 }
 
-
-/**
- * urlencode:
- * @string: the input URL
- *
- * Encode an URL see RFC 2396 and following
- *
- * Returns the new string or NULL in case of error.
- */
-static char *
-urlencode(const char *string)
-{
-size_t len = strlen(string);
-char *buffer;
-char *ptr;
-size_t i;
-
-if (VIR_ALLOC_N(buffer, len * 3 + 1)  0) {
-virReportOOMError();
-return (NULL);
-}
-ptr = buffer;
-for (i = 0; i  len; i++) {
-switch (string[i]) {
-case ' ':
-case '\n':
-case '':
-snprintf(ptr, 4, %%%02x, string[i]);
-ptr += 3;
-break;
-default:
-*ptr = string[i];
-ptr++;
-}
-}
-
-*ptr = 0;
-
-return buffer;
-}
-
 /* PUBLIC FUNCTIONS */
 
 /**
@@ -862,22 +823,9 @@ xenDaemonListDomainsOld(virConnectPtr xend)
 int
 xenDaemonDomainCreateXML(virConnectPtr xend, const char *sexpr)
 {
-int ret, serrno;
-char *ptr;
-
-ptr = urlencode(sexpr);
-if (ptr == NULL) {
-/* this should be caught at the interface but ... */
-virXendError(VIR_ERR_INTERNAL_ERROR,
- %s, _(failed to urlencode the create S-Expr));
-return (-1);
-}
-
-ret = xend_op(xend, , op, create, config, ptr, NULL);
+int ret;
 
-serrno = errno;
-VIR_FREE(ptr);
-errno = serrno;
+ret = xend_op(xend, , op, create, config, sexpr, NULL);
 
 return ret;
 }
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v4] virsh: Add more human-friendly output of domblkstat command

2011-09-08 Thread Peter Krempa

On 09/08/2011 04:24 PM, Eric Blake wrote:

On 09/08/2011 03:11 PM, Peter Krempa wrote:


+{desc, N_(Get device block stats for a running domain.\n\n
+Explanation of fields:\n
+  rd_req- count of read operations\n


That's a bit long for 'virsh help' when compared to other commands.  
I'm not sure if it is sufficient to just list this in virsh.pod, but 
I'm also not opposed to keeping this part of the patch as-is.


This part probably could be removed in the favor of the --human 
parameter and the original texts of the fields would be explained only 
in the man-page.

+/* translations into a more human readable form */
+static const struct _domblkstat_translate domblkstat_human[] = {
+{ VIR_DOMAIN_BLOCK_STATS_READ_BYTES,N_(number of read 
bytes:  ) }, /* 0 */


You are correct that you have to use N_() here to initialize the 
array.  But...



+if (human) {
+/* human friendly output */
+vshPrint(ctl, N_(Device: %s\n), device);
+
+if (stats.rd_req= 0)
+vshPrint (ctl, %s %lld\n, 
domblkstat_human[1].to, stats.rd_req);


...that means down here, you have to translate things.  Also, your 
formatting is not typical (no space between function name and opening 
'('):
Uhm, I'll have to look into how the translation macros work, I learned 
from code, but it was insufficient.


I didn't notice there was a space after function name. It survived my 
copypastefix. :/



+
  /* XXX: The output sequence will be different. */


Can we fix this?  It would be nice if 0.9.4 and 0.9.5 output the 
initial fields in the same order when only the initial fields are 
available, and that only the presence of new fields causes the new 
ordering.
For the sake of backward compatibility, it'd be the best, but the output 
format of the new api would require even more string comparisions to 
ensure tie fields are in correct order.  (I suppose I can't rely on 
every hypervisor driver to feed these in same order).


This is managable, but i think it won't be very nice.


  for (i = 0; i  nparams; i++) {
+/* translate messages into a human readable form, if 
requested */

+field_name = NULL;
+
+if (human)
+for (j = 0; domblkstat_human[j].from != NULL; j++)
+if (STREQ(params[i].field, 
domblkstat_human[j].from)) {

+field_name = domblkstat_human[j].to;


Again, needs translation here, since the array could not be translated:

field_name = _(domblkstat_human[j].to);


+
+BExplanation of fields:
+  rd_req- count of read operations
+  rd_bytes  - count of read bytes
+  rd_total_times- total time read operations took (ns)
+  wr_req- count of write operations
+  wr_bytes  - count of written bytes
+  wr_total_times- total time write operations took (ns)
+  flush_operations  - count of flush operations
+  flush_total_times - total time flush operations took (ns)
+  errs  - error count


Maybe also mention that only the available fields are listed; in the 
case of older server or a hypervisor with less support, then unknown 
fields are omitted

You're right, I'll add that in the next version.

Peter

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


Re: [libvirt] [PATCH v3] virsh: Increase device-detach intelligence

2011-09-08 Thread Michal Privoznik
On 24.08.2011 14:53, Michal Privoznik wrote:
 From: Michal Prívozník mpriv...@redhat.com
 
 Up to now users have to give a full XML description on input when
 device-detaching. If they omitted something it lead to unclear
 error messages (like generated MAC wasn't found, etc.).
 With this patch users can specify only those information which
 specify one device sufficiently precise. Remaining information is
 completed from domain.
 ---
 diff to v2:
 -rebase to current HEAD
 
 diff to v1:
 -rebase to current HEAD
 -add a little bit comments
 
  tools/virsh.c |  266 
 +
  1 files changed, 250 insertions(+), 16 deletions(-)
 
 diff --git a/tools/virsh.c b/tools/virsh.c
 index 1ad84a2..aae8e4e 100644
 --- a/tools/virsh.c
 +++ b/tools/virsh.c
 @@ -10351,6 +10351,226 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
  return true;
  }
  
 +/**
 + * Check if n1 is superset of n2, meaning n1 contains all elements and
 + * attributes as n2 at lest. Including children.
 + * @n1 first node
 + * @n2 second node
 + * return 1 in case n1 covers n2, 0 otherwise.
 + */
 +static int
 +vshNodeIsSuperset(xmlNodePtr n1, xmlNodePtr n2) {
 +xmlNodePtr child1, child2;
 +xmlAttrPtr attr1, attr2;
 +int found;
 +
 +if (!n1  !n2)
 +return 1;
 +
 +if (!n1 || !n2)
 +return 0;
 +
 +if (!xmlStrEqual(n1-name, n2-name))
 +return 0;
 +
 +/* Iterate over n2 attributes and check if n1 contains them*/
 +attr2 = n2-properties;
 +while (attr2) {
 +if (attr2-type == XML_ATTRIBUTE_NODE) {
 +attr1 = n1-properties;
 +found = 0;
 +while (attr1) {
 +if (xmlStrEqual(attr1-name, attr2-name)) {
 +found = 1;
 +break;
 +}
 +attr1 = attr1-next;
 +}
 +if (!found)
 +return 0;
 +if (!xmlStrEqual(BAD_CAST virXMLPropString(n1, (const char *) 
 attr1-name),
 + BAD_CAST virXMLPropString(n2, (const char *) 
 attr2-name)))
 +return 0;
 +}
 +attr2 = attr2-next;
 +}
 +
 +/* and now iterate over n2 children */
 +child2 = n2-children;
 +while (child2) {
 +if (child2-type == XML_ELEMENT_NODE) {
 +child1 = n1-children;
 +found = 0;
 +while (child1) {
 +if (child1-type == XML_ELEMENT_NODE 
 +xmlStrEqual(child1-name, child2-name)) {
 +found = 1;
 +break;
 +}
 +child1 = child1-next;
 +}
 +if (!found)
 +return 0;
 +if (!vshNodeIsSuperset(child1, child2))
 +return 0;
 +}
 +child2 = child2-next;
 +}
 +
 +return 1;
 +}
 +
 +/**
 + * To given domain and (probably incomplete) device XML specification try to
 + * find such device in domain and complete missing parts. This is however
 + * possible when given device XML is sufficiently precise so it addresses 
 only
 + * one device.
 + * @ctl vshControl for error messages printing
 + * @dom domain
 + * @oldXML device XML before
 + * @newXML and after completion
 + * Returns -2 when no such device exists in domain, -3 when given XML 
 selects many
 + *  (is too ambiguous), 0 in case of success. Otherwise returns -1. 
 @newXML
 + *  is touched only in case of success.
 + */
 +static int
 +vshCompleteXMLFromDomain(vshControl *ctl, virDomainPtr dom, char *oldXML,
 + char **newXML) {
 +int funcRet = -1;
 +char *domXML = NULL;
 +xmlDocPtr domDoc = NULL, devDoc = NULL;
 +xmlNodePtr node = NULL;
 +xmlXPathContextPtr domCtxt = NULL, devCtxt = NULL;
 +xmlNodePtr *devices = NULL;
 +xmlSaveCtxtPtr sctxt = NULL;
 +int devices_size;
 +char *xpath;
 +xmlBufferPtr buf = NULL;
 +
 +if (!(domXML = virDomainGetXMLDesc(dom, 0))) {
 +vshError(ctl, _(couldn't get XML description of domain %s),
 + virDomainGetName(dom));
 +goto cleanup;
 +}
 +
 +if (!(domDoc = xmlReadDoc(BAD_CAST domXML, domain.xml, NULL,
 +  XML_PARSE_NOENT | XML_PARSE_NONET |
 +  XML_PARSE_NOERROR | XML_PARSE_NOWARNING))) {
 +vshError(ctl, %s, _(could not parse domain XML));
 +goto cleanup;
 +}
 +
 +if (!(devDoc = xmlReadDoc(BAD_CAST oldXML, device.xml, NULL,
 +  XML_PARSE_NOENT | XML_PARSE_NONET |
 +  XML_PARSE_NOERROR | XML_PARSE_NOWARNING))) {
 +vshError(ctl, %s, _(could not parse device XML));
 +goto cleanup;
 +}
 +
 +node = xmlDocGetRootElement(domDoc);
 +if (!node) {
 +vshError(ctl, %s, _(failed to get domain root element));
 +goto cleanup;
 +}
 +
 +domCtxt 

Re: [libvirt] [PATCH v2] xml: Change virtual file names of xml documents parsed in memory

2011-09-08 Thread Peter Krempa

On 09/08/2011 03:38 PM, Eric Blake wrote:

On 09/08/2011 02:25 PM, Peter Krempa wrote:


15:08:43.581: 525: error : catchXMLError:709 : (domain definition):2: 
error parsing attribute name

namevm1/name
--^


I like it.  ACK, and worth pushing pre-release.


Thanks, but I don't have push privileges. :)

Peter

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


[libvirt] lvm backed storage

2011-09-08 Thread Serge Hallyn
Hi,

When lvm.conf has 'command_names = 1', then all results are prefixed with
the command name.  This confuses libvirt which does not ignore those.  I
thought fixing that would be a simple case of detecting those conditions
at virStorageBackendLogicalMakeVol() and friends, but I was wrong - those
functions are not getting called at all when command_names=1.  I'll keep
nosing around, but it seemed prudent to ping the list and ask what you
think would be the cleanest way to handle this case?

thanks,
-serge

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


[libvirt] [PATCH] selinux: Detect virt_use_nfs boolean set

2011-09-08 Thread Michal Privoznik
If we fail setting label on a file and this file is on NFS share,
it is wise to advise user to set virt_use_nfs selinux boolean
variable.
---
 src/security/security_selinux.c |   11 ++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index ca54f9b..028f5b2 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -420,8 +420,17 @@ SELinuxSetFilecon(const char *path, char *tcon)
  * virt_use_{nfs,usb,pci}  boolean tunables to allow it...
  */
 if (setfilecon_errno != EOPNOTSUPP) {
+const char *errmsg;
+if ((virStorageFileIsSharedFSType(path,
+ VIR_STORAGE_FILE_SHFS_NFS) == 1) 

+security_get_boolean_active(virt_use_nfs) != 1) {
+errmsg = _(unable to set security context '%s' on '%s'. 
+   Consider setting virt_use_nfs);
+} else {
+errmsg = _(unable to set security context '%s' on '%s');
+}
 virReportSystemError(setfilecon_errno,
- _(unable to set security context '%s' on 
'%s'),
+ errmsg,
  tcon, path);
 if (security_getenforce() == 1)
 return -1;
-- 
1.7.3.4

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


Re: [libvirt] [Libvirt-announce] Start of freeze for libvirt-0.9.5 and availability of rc1

2011-09-08 Thread Jason Helfman

On Thu, Sep 08, 2011 at 06:54:08PM +1000, Justin Clift thus spake:

On 08/09/2011, at 5:29 PM, Daniel Veillard wrote:

With a bit of delay, we are entering the freeze for libvirt-0.9.5 .
We may make an exception for the last couple of patches from Hu to
add string to typed parameters and the extra associated patch, as
well as bug fixes too of course !

I have made a release candidate 1 tarball (and associated rpms) at
 ftp://libvirt.org/libvirt/libvirt-0.9.5-rc1.tar.gz

This seems to pass my minimal tests without problems, but please
give it a try too and report problems,



Just tried it on OSX 10.7.1 64-bit.  It barfs with the following:

   CC libvirt_driver_storage_la-storage_backend_scsi.lo
   CC libvirt_net_rpc_server_la-virnetserverprogram.lo
 storage/storage_backend_fs.c:616: error: expected '=', ',', ';', 'asm' or 
'__attribute__' before 'virStorageBackendFileSystemProbe'
 storage/storage_backend_fs.c: In function 'virStorageBackendExecuteMKFS':
 storage/storage_backend_fs.c:635: error: 'MKFS' undeclared (first use in this 
function)
 storage/storage_backend_fs.c:635: error: (Each undeclared identifier is 
reported only once
 storage/storage_backend_fs.c:635: error: for each function it appears in.)
 storage/storage_backend_fs.c: In function 'virStorageBackendMakeFileSystem':
 storage/storage_backend_fs.c:681: error: 'FILESYSTEM_PROBE_NOT_FOUND' 
undeclared (first use in this function)
 make[3]: *** [libvirt_driver_storage_la-storage_backend_fs.lo] Error 1
 make[3]: *** Waiting for unfinished jobs
 make[2]: *** [all] Error 2
 make[1]: *** [all-recursive] Error 1
 make: *** [all] Error 2

Does anyone have time to look into it?

If it's helpful, the Mac Mini in the Westford RH lab was recently
upgraded to OSX 10.7, so could be used for testing/debugging if
someone wants. :)

NOTE - I'm not subscribed to libvir-list, so please CC me on responses. :)

Regards and best wishes,

Justin Clift




I can confirm this build issue on FreeBSD.

-jgh

--
Jason Helfman
System Administrator
experts-exchange.com
http://www.experts-exchange.com/M_4830110.html
E4AD 7CF1 1396 27F6 79DD  4342 5E92 AD66 8C8C FBA5

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


Re: [libvirt] Start of freeze for libvirt-0.9.5 and availability of rc1

2011-09-08 Thread Jim Fehlig
Daniel Veillard wrote:
  With a bit of delay, we are entering the freeze for libvirt-0.9.5 .
 We may make an exception for the last couple of patches from Hu to
 add string to typed parameters and the extra associated patch, as
 well as bug fixes too of course !
   

Would it be possible to get a review of the remaining
virDomainMigrateGetMaxSpeed V2 patches?  Along with the new API, it
would be nice to have a qemu impl in the release.

Thanks!
Jim

https://www.redhat.com/archives/libvir-list/2011-September/msg00087.html
https://www.redhat.com/archives/libvir-list/2011-September/msg00091.html
https://www.redhat.com/archives/libvir-list/2011-September/msg00088.html
https://www.redhat.com/archives/libvir-list/2011-September/msg00089.html
https://www.redhat.com/archives/libvir-list/2011-September/msg00090.html

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


[libvirt] [test-API][PATCH 1/2] update xmlgenerator.py to support for spice graphics type

2011-09-08 Thread Nan Zhang
This extends graphics element for spice XML composing, and support
sub-elements settings for audio, images, streaming and so on:

graphics type='spice' autoport='yes'
image compression='auto_glz'/
jpeg compression='auto'/
zlib compression='auto'/
playback compression='on'/
streaming mode='filter'/
clipboard copypaste='no'/
/graphics
---
 utils/Python/xmlbuilder.py   |9 ++-
 utils/Python/xmlgenerator.py |   51 +++--
 2 files changed, 56 insertions(+), 4 deletions(-)

diff --git a/utils/Python/xmlbuilder.py b/utils/Python/xmlbuilder.py
index 5a0f8c8..3dbe576 100644
--- a/utils/Python/xmlbuilder.py
+++ b/utils/Python/xmlbuilder.py
@@ -297,6 +297,13 @@ if __name__ == __main__:
 params['memory'] = '1048576'
 params['vcpu'] = '2'
 params['inputbus'] = 'usb'
+params['graphtype'] = 'spice'
+params['image'] = 'auto_glz'
+params['jpeg'] = 'auto'
+params['zlib'] = 'auto'
+params['playback'] = 'on'
+params['streaming'] = 'filter'
+params['clipboard'] = 'no'
 params['sound'] = 'ac97'
 params['bootcd'] = '/iso/rhel5.iso'
 
@@ -367,7 +374,7 @@ if __name__ == __main__:
 #
 # get domain snapshot xml string
 #
-params['name'] = 'hello'
+params['snapshotname'] = 'hello'
 params['description'] = 'hello snapshot'
 snapshot_xml = xmlobj.build_domain_snapshot(params)
 
diff --git a/utils/Python/xmlgenerator.py b/utils/Python/xmlgenerator.py
index d57dd33..b61ceb1 100644
--- a/utils/Python/xmlgenerator.py
+++ b/utils/Python/xmlgenerator.py
@@ -235,9 +235,54 @@ def domain_xml(params, install = False):
 
 # graphics
 graphics_element = domain.createElement('graphics')
-graphics_element.setAttribute('type', 'vnc')
-graphics_element.setAttribute('port', '-1')
-graphics_element.setAttribute('keymap', 'en-us')
+if not params.has_key('graphtype'):
+params['graphtype'] == 'vnc'
+
+graphics_element.setAttribute('type', params['graphtype'])
+if params['graphtype'] == 'vnc':
+graphics_element.setAttribute('port', '-1')
+graphics_element.setAttribute('keymap', 'en-us')
+elif params['graphtype'] == 'spice':
+graphics_element.setAttribute('autoport', 'yes')
+if params.has_key('image'):
+image_element = domain.createElement('image')
+# image to set image compression (accepts 
+# auto_glz, auto_lz, quic, glz, lz, off)
+image_element.setAttribute('compression', params['image'])
+graphics_element.appendChild(image_element)
+if params.has_key('jpeg'):
+jpeg_element = domain.createElement('jpeg')
+# jpeg for JPEG compression for images over wan (accepts 
+# auto, never, always)
+jpeg_element.setAttribute('compression', params['jpeg'])
+graphics_element.appendChild(jpeg_element)
+if params.has_key('zlib'):
+zlib_element = domain.createElement('zlib')
+# zlib for configuring wan image compression (accepts 
+# auto, never, always)
+zlib_element.setAttribute('compression', params['zlib'])
+graphics_element.appendChild(zlib_element)
+if params.has_key('playback'):
+playback_element = domain.createElement('playback')
+# playback for enabling audio stream compression (accepts on or 
off)
+playback_element.setAttribute('compression', params['playback'])
+graphics_element.appendChild(playback_element)
+if params.has_key('streaming'):
+streaming_element = domain.createElement('streaming')
+# streamming for settings it's mode attribute to one of 
+# filter, all or off
+streaming_element.setAttribute('mode', params['streaming'])
+graphics_element.appendChild(streaming_element)
+if params.has_key('clipboard'):
+clipboard_element = domain.createElement('clipboard')
+# Copy  Paste functionality is enabled by default, and can 
+# be disabled by setting the copypaste property to no
+clipboard_element.setAttribute('copypaste', params['clipboard'])
+graphics_element.appendChild(clipboard_element)
+else:
+print 'Wrong graphics type was specified.'
+sys.exit(1)
+
 devices_element.appendChild(graphics_element)
 domain_element.appendChild(devices_element)
 
-- 
1.7.4.4

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


[libvirt] [test-API][PATCH 2/2] add case for testing spice compression options

2011-09-08 Thread Nan Zhang
---
 repos/domain/spice_options.py |  113 +
 1 files changed, 113 insertions(+), 0 deletions(-)
 create mode 100644 repos/domain/spice_options.py

diff --git a/repos/domain/spice_options.py b/repos/domain/spice_options.py
new file mode 100644
index 000..660805c
--- /dev/null
+++ b/repos/domain/spice_options.py
@@ -0,0 +1,113 @@
+#!/usr/bin/evn python
+Configuring spice compression options
+
+
+__author__ = 'Nan Zhang: nzh...@redhat.com'
+__date__ = 'Thu Sep 8, 2011'
+__version__ = '0.1.0'
+__credits__ = 'Copyright (C) 2011 Red Hat, Inc.'
+__all__ = ['usage', 'spice_config']
+
+import os
+import re
+import sys
+from xml.dom import minidom
+
+def append_path(path):
+Append root path of package
+if path in sys.path:
+pass
+else:
+sys.path.append(path)
+
+pwd = os.getcwd()
+result = re.search('(.*)libvirt-test-API', pwd)
+append_path(result.group(0))
+
+from lib import connectAPI
+from lib import domainAPI
+from utils.Python import utils
+from utils.Python import xmlbuilder
+from exception import LibvirtAPI
+
+def usage():
+print '''usage: mandatory arguments:
+   guestname
+   image
+   jpeg
+   zlib
+   playback
+  '''
+
+def check_params(params):
+Verify inputing parameter dictionary
+logger = params['logger']
+keys = ['guestname', 'image', 'jpeg', 'zlib', 'playback']
+for key in keys:
+if key not in params:
+logger.error(%s is required %key)
+usage()
+return 1
+return 0
+
+def spice_options(params):
+check spice options
+# Initiate and check parameters
+params_check_result = check_params(params)
+if params_check_result:
+return 1
+logger = params['logger']
+guestname = params['guestname']
+image = params['image']
+jpeg = params['jpeg']
+zlib = params['zlib']
+playback = params['playback']
+
+# Connect to local hypervisor connection URI
+util = utils.Utils()
+uri = util.get_uri('127.0.0.1')
+conn = connectAPI.ConnectAPI()
+virconn = conn.open(uri)
+
+caps = conn.get_caps()
+logger.debug(caps)
+
+# Get domain xml
+domobj = domainAPI.DomainAPI(virconn)
+xmlobj = domobj.get_xml_desc(guestname)
+prexml = xmlobj.split('\n')
+postxml = ''
+for i in range(len(prexml)):
+postxml = postxml + prexml[i].lstrip()
+domxml = minidom.parseString(postxml)
+
+# Check spice options in 'graphcis' tag
+graphTag = domxml.getElementsByTagName(graphics):
+try:
+try:
+for graphTag in domxml.getElementsByTagName(graphics):
+assert len(graphTag.childNodes) == 4
+assert graphTag.childNodes[0].getAttribute(compression) \
+ == params['image']
+assert graphTag.childNodes[1].getAttribute(compression) \
+ == params['jpeg']
+assert graphTag.childNodes[2].getAttribute(compression) \
+ == params['zlib']
+assert graphTag.childNodes[3].getAttribute(compression) \
+ == params['playback']
+except AssertionError:
+logger.error(Wrong checks happend on spice options.)
+conn.close()
+logger.info(closed hypervisor connection)
+return 1
+finally:
+logger.info(spice options were checked successfully.)
+conn.close()
+logger.info(closed hypervisor connection)
+
+return 0
+
+def spice_options_clean():
+Clean testing environment
+pass
+
-- 
1.7.4.4

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


[libvirt] how did libvirt manage Virtual Network?

2011-09-08 Thread Wayne Xia

Working at the network management, I am a bit confused about the
VLAN model in libvirt.

in the xml definition, there is a section as following:

  devices
interface type='network'
  source network='default'/
/interface
...
interface type='network'
  source network='default' portgroup='engineering'/
  target dev='vnet7'/
  mac address=00:11:22:33:44:55/
  virtualport type='802.1Qbg'
parameters managerid='11' typeid='1193047' typeidversion='2'
instanceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'/
  /virtualport

/interface
  /devices


What is the really meaning of its related parameters of
virtualport? I want to discover informations such as VLAN id,
the switch type( software switch or hardware switch), connecting
relationship, but from the xml I can only found managerid. I am not 
sure how to map these xml information to those I needed, could I 
consider managerid as VLAN id, and a portgroup as a specified VLAN group?

By the way to use virtualport, what components should I install on
Linux?

--
Best Regards

Wayne Xia
mail:xiaw...@linux.vnet.ibm.com
tel:86-010-82450803

___
kvm-cstl mailing list lt;kvm-c...@lists.linux.ibm.com
To unsubscribe from the list, change your list options
or if you have forgotten your list password visit:
http://lists.linux.ibm.com/mailman/listinfo/kvm-cstl

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


Re: [libvirt] [test-API][PATCH 2/2] add case for testing spice compression options

2011-09-08 Thread Alex Jia

On 09/09/2011 02:41 AM, Nan Zhang wrote:

---
  repos/domain/spice_options.py |  113 +
  1 files changed, 113 insertions(+), 0 deletions(-)
  create mode 100644 repos/domain/spice_options.py

diff --git a/repos/domain/spice_options.py b/repos/domain/spice_options.py
new file mode 100644
index 000..660805c
--- /dev/null
+++ b/repos/domain/spice_options.py
@@ -0,0 +1,113 @@
+#!/usr/bin/evn python

s/evn/env/.

+Configuring spice compression options
+
+
+__author__ = 'Nan Zhang: nzh...@redhat.com'
+__date__ = 'Thu Sep 8, 2011'
+__version__ = '0.1.0'
+__credits__ = 'Copyright (C) 2011 Red Hat, Inc.'
+__all__ = ['usage', 'spice_config']
+
+import os
+import re
+import sys
+from xml.dom import minidom
+
+def append_path(path):
+Append root path of package
+if path in sys.path:
+pass
+else:
+sys.path.append(path)
+
+pwd = os.getcwd()
+result = re.search('(.*)libvirt-test-API', pwd)
+append_path(result.group(0))
+
+from lib import connectAPI
+from lib import domainAPI
+from utils.Python import utils
+from utils.Python import xmlbuilder

Unused import xmlbuilder.

+from exception import LibvirtAPI

Unused import LibvirtAPI.

+
+def usage():
+print '''usage: mandatory arguments:
+   guestname
+   image
+   jpeg
+   zlib
+   playback
+  '''
+
+def check_params(params):
+Verify inputing parameter dictionary
+logger = params['logger']
+keys = ['guestname', 'image', 'jpeg', 'zlib', 'playback']
+for key in keys:
+if key not in params:
+logger.error(%s is required %key)
+usage()
+return 1
+return 0
+
+def spice_options(params):
+check spice options
+# Initiate and check parameters
+params_check_result = check_params(params)
+if params_check_result:
+return 1
+logger = params['logger']
+guestname = params['guestname']
+image = params['image']
+jpeg = params['jpeg']
+zlib = params['zlib']
+playback = params['playback']

Unused variable 'image', 'jpeg', 'zlib' and 'playback'.

+
+# Connect to local hypervisor connection URI
+util = utils.Utils()
+uri = util.get_uri('127.0.0.1')
+conn = connectAPI.ConnectAPI()
+virconn = conn.open(uri)
+
+caps = conn.get_caps()
+logger.debug(caps)
+
+# Get domain xml
+domobj = domainAPI.DomainAPI(virconn)
+xmlobj = domobj.get_xml_desc(guestname)
+prexml = xmlobj.split('\n')
+postxml = ''
+for i in range(len(prexml)):
+postxml = postxml + prexml[i].lstrip()
+domxml = minidom.parseString(postxml)
+
+# Check spice options in 'graphcis' tag
+graphTag = domxml.getElementsByTagName(graphics):

Remove useless :, this will hit a syntax error.


Alex

+try:
+try:
+for graphTag in domxml.getElementsByTagName(graphics):
+assert len(graphTag.childNodes) == 4
+assert graphTag.childNodes[0].getAttribute(compression) \
+ == params['image']
+assert graphTag.childNodes[1].getAttribute(compression) \
+ == params['jpeg']
+assert graphTag.childNodes[2].getAttribute(compression) \
+ == params['zlib']
+assert graphTag.childNodes[3].getAttribute(compression) \
+ == params['playback']
+except AssertionError:
+logger.error(Wrong checks happend on spice options.)
+conn.close()
+logger.info(closed hypervisor connection)
+return 1
+finally:
+logger.info(spice options were checked successfully.)
+conn.close()
+logger.info(closed hypervisor connection)
+
+return 0
+
+def spice_options_clean():
+Clean testing environment
+pass
+


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


Re: [libvirt] [test-API][PATCH v2] Add test case update_devflag.py for update device flag

2011-09-08 Thread Guannan Ren

On 09/08/2011 11:29 AM, Nan Zhang wrote:

---
  repos/domain/update_devflag.py |  163 
  1 files changed, 163 insertions(+), 0 deletions(-)
  create mode 100644 repos/domain/update_devflag.py

diff --git a/repos/domain/update_devflag.py b/repos/domain/update_devflag.py
new file mode 100644
index 000..287f2a5
--- /dev/null
+++ b/repos/domain/update_devflag.py
@@ -0,0 +1,163 @@
+#!/usr/bin/evn python
+Update virtual device to guest from an XML file
+
+
+__author__ = 'Nan Zhang: nzh...@redhat.com'
+__date__ = 'Fri Sep 2, 2011'
+__version__ = '0.1.0'
+__credits__ = 'Copyright (C) 2011 Red Hat, Inc.'
+__all__ = ['usage', 'update_devflag']
+
+import os
+import re
+import sys
+import commands
+from xml.dom import minidom
+
+def append_path(path):
+Append root path of package
+if path in sys.path:
+pass
+else:
+sys.path.append(path)
+
+pwd = os.getcwd()
+result = re.search('(.*)libvirt-test-API', pwd)
+append_path(result.group(0))
+
+from lib import connectAPI
+from lib import domainAPI
+from utils.Python import utils
+from utils.Python import xmlbuilder
+from exception import LibvirtAPI
+
+def usage():
+print '''usage: mandatory arguments:
+   guestname
+   devtype
+  '''
+

  I think this is not the good way to show the help message.
  Defining it in the description is better like this.
   Update virtual device to guest from an XML file
domain:update_devflag
 guestname
 xxx
  devtype
 cdrom|floppy
  

+def check_params(params):
+Verify inputing parameter dictionary
+logger = params['logger']
+keys = ['guestname', 'devtype']
+for key in keys:
+if key not in params:
+logger.error(%s is required %key)
+usage()
+return 1
+return 0
+
+def create_image(params, img_name, img_size):
+Create an image file
+logger = params['logger']
+stat, ret = commands.getstatusoutput(dd if=/dev/zero of=%s bs=1 \
+count=1 seek=%s % (img_name, img_size))
+if stat == 0:
+logger.debug(create image result:\n%s % ret)
+return True
+else:
+return False
+
+def check_updated_device(params, guestname, domobj, srcfile):
+Check if the device is updated
+logger = params['logger']
+xmlobj = domobj.get_xml_desc(guestname)
+domxml = minidom.parseString(xmlobj)
+
+for diskTag in domxml.getElementsByTagName(source):
+if diskTag.parentNode.getAttribute(device) == 'cdrom':
+upfile = diskTag.getAttribute(file)
+elif diskTag.parentNode.getAttribute('device') == 'floppy':
+upfile = diskTag.getAttribute(file)
+
+if upfile == srcfile:
+return False, upfile
+else:
+return True, upfile


The checking the simple, at least we should login to the guest,
to check if the device could be functional like being mounted 
successfully.




+
+def update_devflag(params):
+Update virtual device to a domain from xml
+
+# Initiate and check parameters
+params_check_result = check_params(params)
+if params_check_result:
+return 1
+logger = params['logger']
+guestname = params['guestname']
+devtype = params['devtype']


  The update-device is for inactive domain, so we need to check 
if the domain given

  is in right state.


+if devtype == 'cdrom':
+xmlargs = {}
+xmlargs['guestname'] = guestname
+xmlargs['guesttype'] = 'kvm'
+xmlargs['hdmodel'] = 'ide'
+xmlargs['bootcd'] = '/var/lib/libvirt/boot/cdrom.img'
+srcfile = xmlargs['bootcd']
+create_image(params, srcfile, '100M')


 It's better to check the return value of create_image.


+elif devtype == 'floppy':
+xmlargs = {}
+xmlargs['guestname'] = guestname
+xmlargs['floppysource'] = '/var/lib/libvirt/boot/floppy.img'
+srcfile = xmlargs['floppysource']
+create_image(params, srcfile, '2M')


same like above


+else:
+srcfile = None
+logger.error(Wrong device type was specified.)
+return 1
+
+if not params.has_key('flag'):
+flag = domainAPI.VIR_DOMAIN_AFFECT_CONFIG
+
+# Connect to local hypervisor connection URI
+util = utils.Utils()
+uri = util.get_uri('127.0.0.1')
+conn = connectAPI.ConnectAPI()
+virconn = conn.open(uri)
+
+caps = conn.get_caps()
+logger.debug(caps)
+
+# Generate device XML for updating
+domobj = domainAPI.DomainAPI(virconn)
+newxmlobj = xmlbuilder.XmlBuilder()


  Before generating new device xml description, the domain have to
  the original xml definition first for update, from your 
testing scenario,