[libvirt] [libvirt-php] add get name and path for storage volume
by Lyre
---
src/libvirt.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
src/libvirt_php.h | 2 ++
2 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 1608774..3678974 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -90,6 +90,8 @@ static function_entry libvirt_functions[] = {
PHP_FE(libvirt_storagepool_lookup_by_name,NULL)
PHP_FE(libvirt_storagepool_get_info,NULL)
PHP_FE(libvirt_storagevolume_lookup_by_name,NULL)
+ PHP_FE(libvirt_storagevolume_get_name,NULL)
+ PHP_FE(libvirt_storagevolume_get_path,NULL)
PHP_FE(libvirt_storagevolume_get_info,NULL)
PHP_FE(libvirt_storagevolume_get_xml_desc,NULL)
PHP_FE(libvirt_storagevolume_create_xml,NULL)
@@ -2644,6 +2646,48 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_name)
}
/*
+ Function name: libvirt_storagevolume_get_name
+ Since version: 0.4.1(-1)
+ Description: Function is used to get the storage volume name
+ Arguments: @res [resource]: libvirt storagevolume resource
+ Returns: storagevolume name
+*/
+PHP_FUNCTION(libvirt_storagevolume_get_name)
+{
+ php_libvirt_volume *volume = NULL;
+ zval *zvolume;
+ const char *val;
+
+ GET_VOLUME_FROM_ARGS ("r", &zvolume);
+
+ val = virStorageVolGetName (volume->volume);
+ if (val == NULL) RETURN_FALSE;
+
+ RETURN_STRING (val, 1);
+}
+
+/*
+ Function name: libvirt_storagevolume_path
+ Since version: 0.4.1(-1)
+ Description: Function is used to get the storage volume path
+ Arguments: @res [resource]: libvirt storagevolume resource
+ Returns: storagevolume path
+*/
+PHP_FUNCTION(libvirt_storagevolume_get_path)
+{
+ php_libvirt_volume *volume = NULL;
+ zval *zvolume;
+ char *val;
+
+ GET_VOLUME_FROM_ARGS ("r", &zvolume);
+
+ val = virStorageVolGetPath (volume->volume);
+ if (val == NULL) RETURN_FALSE;
+
+ RETURN_STRING (val, 1);
+}
+
+/*
Function name: libvirt_storagevolume_get_info
Since version: 0.4.1(-1)
Description: Function is used to get the storage volume information
diff --git a/src/libvirt_php.h b/src/libvirt_php.h
index 3367943..60203de 100644
--- a/src/libvirt_php.h
+++ b/src/libvirt_php.h
@@ -154,6 +154,8 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_name);
PHP_FUNCTION(libvirt_storagepool_list_volumes);
PHP_FUNCTION(libvirt_storagepool_get_info);
PHP_FUNCTION(libvirt_storagevolume_lookup_by_name);
+PHP_FUNCTION(libvirt_storagevolume_get_name);
+PHP_FUNCTION(libvirt_storagevolume_get_path);
PHP_FUNCTION(libvirt_storagevolume_get_info);
PHP_FUNCTION(libvirt_storagevolume_get_xml_desc);
PHP_FUNCTION(libvirt_storagevolume_create_xml);
--
1.7.3.4
13 years, 8 months
[libvirt] [PATCH] v2: Fix uninitialized variable & error reporting in LXC veth setup
by Daniel P. Berrange
THe veth setup in LXC had a couple of flaws, first brInit did
not report any error when it failed. Second vethCreate() did
not correctly initialize the variable containing the return
code, so could report failure even when it succeeded.
* src/lxc/lxc_driver.c: Report error when brInit fails
* src/lxc/veth.c: Fix uninitialized variable
---
src/lxc/lxc_driver.c | 8 ++++++--
src/lxc/veth.c | 33 ++++++++++++++++++++++-----------
2 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 79b6879..9b131cc 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1024,9 +1024,13 @@ static int lxcSetupInterfaces(virConnectPtr conn,
int rc = -1, i;
char *bridge = NULL;
brControl *brctl = NULL;
+ int ret;
- if (brInit(&brctl) != 0)
+ if ((ret = brInit(&brctl)) != 0) {
+ virReportSystemError(ret, "%s",
+ _("Unable to initialize bridging"));
return -1;
+ }
for (i = 0 ; i < def->nnets ; i++) {
char *parentVeth;
@@ -1095,7 +1099,7 @@ static int lxcSetupInterfaces(virConnectPtr conn,
goto error_exit;
}
- if (0 != (rc = brAddInterface(brctl, bridge, parentVeth))) {
+ if ((ret = brAddInterface(brctl, bridge, parentVeth)) != 0) {
virReportSystemError(rc,
_("Failed to add %s device to %s"),
parentVeth, bridge);
diff --git a/src/lxc/veth.c b/src/lxc/veth.c
index 0fa76cf..26bf4ff 100644
--- a/src/lxc/veth.c
+++ b/src/lxc/veth.c
@@ -90,33 +90,40 @@ static int getFreeVethName(char **veth, int startDev)
*/
int vethCreate(char** veth1, char** veth2)
{
- int rc;
+ int rc = -1;
const char *argv[] = {
"ip", "link", "add", NULL, "type", "veth", "peer", "name", NULL, NULL
};
int vethDev = 0;
bool veth1_alloc = false;
+ bool veth2_alloc = false;
VIR_DEBUG("veth1: %s veth2: %s", NULLSTR(*veth1), NULLSTR(*veth2));
if (*veth1 == NULL) {
- vethDev = getFreeVethName(veth1, vethDev);
- if (vethDev < 0)
- return vethDev;
+ if ((vethDev = getFreeVethName(veth1, vethDev)) < 0)
+ goto cleanup;
VIR_DEBUG("Assigned veth1: %s", *veth1);
veth1_alloc = true;
}
argv[3] = *veth1;
- while (*veth2 == NULL || STREQ(*veth1, *veth2)) {
- VIR_FREE(*veth2);
- vethDev = getFreeVethName(veth2, vethDev + 1);
- if (vethDev < 0) {
+ while (*veth2 == NULL) {
+ if ((vethDev = getFreeVethName(veth2, vethDev + 1)) < 0) {
if (veth1_alloc)
VIR_FREE(*veth1);
- return vethDev;
+ goto cleanup;
+ }
+
+ /* Just make sure they didn't accidentally get same name */
+ if (STREQ(*veth1, *veth2)) {
+ vethDev++;
+ VIR_FREE(*veth2);
+ continue;
}
+
VIR_DEBUG("Assigned veth2: %s", *veth2);
+ veth2_alloc = true;
}
argv[8] = *veth2;
@@ -124,10 +131,14 @@ int vethCreate(char** veth1, char** veth2)
if (virRun(argv, NULL) < 0) {
if (veth1_alloc)
VIR_FREE(*veth1);
- VIR_FREE(*veth2);
- rc = -1;
+ if (veth2_alloc)
+ VIR_FREE(*veth2);
+ goto cleanup;
}
+ rc = 0;
+
+cleanup:
return rc;
}
--
1.7.1
13 years, 8 months
[libvirt] [PATCH] udev: fix regression with qemu:///session
by Eric Blake
https://bugzilla.redhat.com/show_bug.cgi?id=684655 points out
a regression introduced in commit 2215050edd - non-root users
can't connect to qemu:///session because libvirtd dies when
it can't use pciaccess initialization.
* src/node_device/node_device_udev.c (udevDeviceMonitorStartup):
Don't abort udev driver (and libvirtd overall) if non-root user
can't use pciaccess.
---
src/node_device/node_device_udev.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index be6a371..44df16e 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1,7 +1,7 @@
/*
* node_device_udev.c: node device enumeration - libudev implementation
*
- * Copyright (C) 2009-2010 Red Hat, Inc.
+ * Copyright (C) 2009-2011 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1589,7 +1589,7 @@ out:
return ret;
}
-static int udevDeviceMonitorStartup(int privileged ATTRIBUTE_UNUSED)
+static int udevDeviceMonitorStartup(int privileged)
{
udevPrivate *priv = NULL;
struct udev *udev = NULL;
@@ -1597,11 +1597,16 @@ static int udevDeviceMonitorStartup(int privileged ATTRIBUTE_UNUSED)
int pciret;
if ((pciret = pci_system_init()) != 0) {
- char ebuf[256];
- VIR_ERROR(_("Failed to initialize libpciaccess: %s"),
- virStrerror(pciret, ebuf, sizeof ebuf));
- ret = -1;
- goto out;
+ /* 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) {
+ char ebuf[256];
+ VIR_ERROR(_("Failed to initialize libpciaccess: %s"),
+ virStrerror(pciret, ebuf, sizeof ebuf));
+ ret = -1;
+ goto out;
+ }
}
if (VIR_ALLOC(priv) < 0) {
--
1.7.4
13 years, 8 months
[libvirt] [PATCH] do not report OOM error when prepareCall() failed
by Wen Congyang
We have reported error in the function prepareCall(), and
the error is not only OOM error. So we should not report
OOM error in the function call() when prepareCall() failed.
---
src/remote/remote_driver.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index b844d9a..5f3e288 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -10832,7 +10832,6 @@ call (virConnectPtr conn, struct private_data *priv,
ret_filter, ret);
if (!thiscall) {
- virReportOOMError();
return -1;
}
--
1.7.1
13 years, 8 months
[libvirt] [RFC PATCH 0/2] virObject for reference-counting
by Hu Tao
virObject is a base struct that manages reference-counting. structs
that need the ability of reference-counting can inherit from
virObject and implement ref/unref interface easily.
The goal of this series is to make reference-counting easy to use,
and improve the current libvir reference-counting mechanism. The
plan is to update all existing structs that use reference-counting
to use virObject if virObject is acceptable.
Patch 1 implements virObject, patch 2 is an illstration of usage of
virObject. This series is in draft stage, any comments are welcome.
Hu Tao (2):
Add virObject.
qemu: use virObject to manages reference-counting for qemu monitor
src/Makefile.am | 1 +
src/libvirt_private.syms | 5 ++
src/qemu/qemu_domain.c | 26 +----------
src/qemu/qemu_monitor.c | 106 ++++++++++++++++++++++++++--------------------
src/qemu/qemu_monitor.h | 4 +-
src/util/object.c | 55 ++++++++++++++++++++++++
src/util/object.h | 39 +++++++++++++++++
7 files changed, 164 insertions(+), 72 deletions(-)
create mode 100644 src/util/object.c
create mode 100644 src/util/object.h
--
1.7.3.1
--
Thanks,
Hu Tao
13 years, 8 months
[libvirt] Question about virConnectDomainXMLToNative
by Michal Novotny
Hi,
I've been investigating the virConnectDomainXMLToNative() format option
and I found out the virConnectDomainXMLToNative() calls the
conn->driver->domainXMLToNative() function and passes the format to the
driver function where the check whether format is valid or not is being
performed. Unfortunately I was unable to get the list of supported
format strings (like "qemu-argv"/"xen-xm"/"xen-sexpr" etc.) so I'd like
to ask whether there is some API to get all the formats supported by the
driver or not.
If not, wouldn't it be worth it to add some API like
virConnectGetDomainNativeFormats() or something to return the format
option for the connection?
I guess many people would be having issues with that and although it's
documented in the virsh man pages what if somebody will be using some
other application than virsh or you add some formatting option however
you forget to add it to the man page?
I think it's worth it to consider adding
conn->driver->domainNativeFormats() to the driver and placing it nearby
the conn->driver->domainXMLToNative() function in the driver (like right
above qemuDomainXMLToNative() etc.).
Or is there some API way to get the domain format strings that I'm not
aware of, i.e. that I didn't find by my investigation?
Thanks,
Michal
--
Michal Novotny<minovotn(a)redhat.com>, RHCE
Virtualization Team (xen userspace), Red Hat
13 years, 8 months
[libvirt] [PATCH 0/2] qemu: fallback to HMP drive_add/drive_del
by Jiri Denemark
Hu Tao (1):
qemu: fallback to HMP drive_add/drive_del
Jiri Denemark (1):
qemu: Detect support for HMP passthrough
src/qemu/qemu_monitor.c | 14 ++++++-
src/qemu/qemu_monitor.h | 2 +
src/qemu/qemu_monitor_json.c | 80 ++++++++++++++++++++++++++++++++++-------
src/qemu/qemu_monitor_json.h | 2 +
4 files changed, 82 insertions(+), 16 deletions(-)
--
1.7.4.1
13 years, 8 months