[libvirt] [PATCH v2] Fix error reporting when fetching SCSI/LVM keys
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The current virStorageFileGet{LVM,SCSI}Key methods return
the key as the return value. Unfortunately it is desirable
for "NULL" to be a valid return value, as well as an error
indicator. Thus the returned key must instead be provided
as an out-parameter.
When we invoke lvs or scsi_id to extract ID for block devices,
we don't want virCommandWait logging errors messages. Thus we
must explicitly check 'status != 0', rather than letting
virCommandWait do it.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/util/storage_file.c | 74 ++++++++++++++++++++++++++++++++-----------------
src/util/storage_file.h | 6 ++--
2 files changed, 53 insertions(+), 27 deletions(-)
diff --git a/src/util/storage_file.c b/src/util/storage_file.c
index 17a47cf..fe7e8b8 100644
--- a/src/util/storage_file.c
+++ b/src/util/storage_file.c
@@ -1192,62 +1192,75 @@ int virStorageFileIsClusterFS(const char *path)
}
#ifdef LVS
-char *virStorageFileGetLVMKey(const char *path)
+int virStorageFileGetLVMKey(const char *path,
+ char **key)
{
/*
* # lvs --noheadings --unbuffered --nosuffix --options "uuid" LVNAME
* 06UgP5-2rhb-w3Bo-3mdR-WeoL-pytO-SAa2ky
*/
- char *key = NULL;
+ int status;
virCommandPtr cmd = virCommandNewArgList(
LVS,
"--noheadings", "--unbuffered", "--nosuffix",
"--options", "uuid", path,
NULL
);
+ int ret = -1;
+
+ *key = NULL;
/* Run the program and capture its output */
- virCommandSetOutputBuffer(cmd, &key);
- if (virCommandRun(cmd, NULL) < 0)
+ virCommandSetOutputBuffer(cmd, key);
+ if (virCommandRun(cmd, &status) < 0)
goto cleanup;
- if (key) {
+ /* Explicitly check status == 0, rather than passing NULL
+ * to virCommandRun because we don't want to raise an actual
+ * error in this scenario, just return a NULL key.
+ */
+
+ if (status == 0 && *key) {
char *nl;
- char *tmp = key;
+ char *tmp = *key;
/* Find first non-space character */
while (*tmp && c_isspace(*tmp)) {
tmp++;
}
/* Kill leading spaces */
- if (tmp != key)
- memmove(key, tmp, strlen(tmp)+1);
+ if (tmp != *key)
+ memmove(*key, tmp, strlen(tmp)+1);
/* Kill trailing newline */
- if ((nl = strchr(key, '\n')))
+ if ((nl = strchr(*key, '\n')))
*nl = '\0';
}
- if (key && STREQ(key, ""))
- VIR_FREE(key);
+ ret = 0;
cleanup:
+ if (*key && STREQ(*key, ""))
+ VIR_FREE(*key);
+
virCommandFree(cmd);
- return key;
+ return ret;
}
#else
-char *virStorageFileGetLVMKey(const char *path)
+int virStorageFileGetLVMKey(const char *path,
+ char **key)
{
virReportSystemError(ENOSYS, _("Unable to get LVM key for %s"), path);
- return NULL;
+ return -1;
}
#endif
#ifdef HAVE_UDEV
-char *virStorageFileGetSCSIKey(const char *path)
+int virStorageFileGetSCSIKey(const char *path,
+ char **key)
{
- char *key = NULL;
+ int status;
virCommandPtr cmd = virCommandNewArgList(
"/lib/udev/scsi_id",
"--replace-whitespace",
@@ -1255,30 +1268,41 @@ char *virStorageFileGetSCSIKey(const char *path)
"--device", path,
NULL
);
+ int ret = -1;
+
+ *key = NULL;
/* Run the program and capture its output */
- virCommandSetOutputBuffer(cmd, &key);
- if (virCommandRun(cmd, NULL) < 0)
+ virCommandSetOutputBuffer(cmd, key);
+ if (virCommandRun(cmd, &status) < 0)
goto cleanup;
- if (key && STRNEQ(key, "")) {
- char *nl = strchr(key, '\n');
+ /* Explicitly check status == 0, rather than passing NULL
+ * to virCommandRun because we don't want to raise an actual
+ * error in this scenario, just return a NULL key.
+ */
+ if (status == 0 && *key) {
+ char *nl = strchr(*key, '\n');
if (nl)
*nl = '\0';
- } else {
- VIR_FREE(key);
}
+ ret = 0;
+
cleanup:
+ if (*key && STREQ(*key, ""))
+ VIR_FREE(*key);
+
virCommandFree(cmd);
- return key;
+ return ret;
}
#else
-char *virStorageFileGetSCSIKey(const char *path)
+int virStorageFileGetSCSIKey(const char *path,
+ char **key)
{
virReportSystemError(ENOSYS, _("Unable to get SCSI key for %s"), path);
- return NULL;
+ return -1;
}
#endif
diff --git a/src/util/storage_file.h b/src/util/storage_file.h
index 9e4516e..6fbd275 100644
--- a/src/util/storage_file.h
+++ b/src/util/storage_file.h
@@ -101,7 +101,9 @@ int virStorageFileIsClusterFS(const char *path);
int virStorageFileIsSharedFSType(const char *path,
int fstypes);
-char *virStorageFileGetLVMKey(const char *path);
-char *virStorageFileGetSCSIKey(const char *path);
+int virStorageFileGetLVMKey(const char *path,
+ char **key);
+int virStorageFileGetSCSIKey(const char *path,
+ char **key);
#endif /* __VIR_STORAGE_FILE_H__ */
--
1.7.11.7
12 years
[libvirt] [PATCH] conf: Remove duplicate declaration of virNetworkDNSDefPtr
by Jiri Denemark
---
Pushed as trivial build-breaker.
src/conf/network_conf.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index 49fc0ca..8adc2a4 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -106,24 +106,22 @@ struct _virNetworkDNSHostDef {
typedef struct _virNetworkDNSDef virNetworkDNSDef;
typedef virNetworkDNSDef *virNetworkDNSDefPtr;
struct _virNetworkDNSDef {
size_t ntxts;
virNetworkDNSTxtDefPtr txts;
size_t nhosts;
virNetworkDNSHostDefPtr hosts;
size_t nsrvs;
virNetworkDNSSrvDefPtr srvs;
};
-typedef struct _virNetworkDNSDef *virNetworkDNSDefPtr;
-
typedef struct _virNetworkIpDef virNetworkIpDef;
typedef virNetworkIpDef *virNetworkIpDefPtr;
struct _virNetworkIpDef {
char *family; /* ipv4 or ipv6 - default is ipv4 */
virSocketAddr address; /* Bridge IP address */
/* One or the other of the following two will be used for a given
* IP address, but never both. The parser guarantees this.
* Use virNetworkIpDefPrefix/virNetworkIpDefNetmask rather
* than accessing the data directly - these utility functions
* will convert one into the other as necessary.
--
1.8.0
12 years
[libvirt] [PATCH 0/2] virsh: catch disconnections for non-default connections too
by Ján Tomko
Right now virsh says 'Failed to reconnect to the hypervisor' even for the
first connection to the default URI and it fails to catch disconnections for
connections to the non-default URI.
Ján Tomko (2):
virsh: don't lie about reconnection in vshReconnect
virsh: use vshReconnect for non-default connections too
tools/virsh.c | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
--
1.7.8.6
12 years
[libvirt] [PATCH] Support network boot for HVM guests in libxl
by Jim Fehlig
The libxl driver ignored boot devices in the domain config,
preventing PXE booting HVM domains. This patch accounts for
user-specified boot devices when building the libxl domain
configuration.
---
I'm inclined to call this a bug fix since it is not possible
to network boot HVM guests without this patch. Would it be
ok to push this for 1.0.1?
src/libxl/libxl_conf.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 5b6d6fb..4c0e961 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -438,6 +438,8 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
b_info->max_memkb = def->mem.max_balloon;
b_info->target_memkb = def->mem.cur_balloon;
if (hvm) {
+ char bootorder[VIR_DOMAIN_BOOT_LAST+1];
+
libxl_defbool_set(&b_info->u.hvm.pae,
def->features & (1 << VIR_DOMAIN_FEATURE_PAE));
libxl_defbool_set(&b_info->u.hvm.apic,
@@ -450,6 +452,34 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
libxl_defbool_set(&b_info->u.hvm.hpet, 1);
}
}
+ for (i = 0 ; i < def->os.nBootDevs ; i++) {
+ switch (def->os.bootDevs[i]) {
+ case VIR_DOMAIN_BOOT_FLOPPY:
+ bootorder[i] = 'a';
+ break;
+ default:
+ case VIR_DOMAIN_BOOT_DISK:
+ bootorder[i] = 'c';
+ break;
+ case VIR_DOMAIN_BOOT_CDROM:
+ bootorder[i] = 'd';
+ break;
+ case VIR_DOMAIN_BOOT_NET:
+ bootorder[i] = 'n';
+ break;
+ }
+ }
+ if (def->os.nBootDevs == 0) {
+ bootorder[0] = 'c';
+ bootorder[1] = '\0';
+ }
+ else {
+ bootorder[def->os.nBootDevs] = '\0';
+ }
+ if ((b_info->u.hvm.boot = strdup(bootorder)) == NULL) {
+ virReportOOMError();
+ goto error;
+ }
/*
* The following comment and calculation were taken directly from
--
1.8.0.1
12 years
[libvirt] [PATCH 00/14 v4] Implement virtlockd daemon
by Daniel P. Berrange
This is an update of
https://www.redhat.com/archives/libvir-list/2012-September/msg00816.html
This series was previously fully acked, but before pushing I
noticed some problems and stopped. Since then I've done quite
a few more changes to rebase to latest GIT & follow new best
practice.
I've also added support for a config file for the lockd plugin
and the ability to use custom lockspaces for LVM and SCSI IDs.
I've also added support to acquire leases based on a SHA256
sum of the file, instead of directly on the file
As such I don't feel comfortable pushing, without further
reviews.
While we're past the freeze date, I'd like to request an
exception, for all except the 14th patch. Without the
14th patch, this series has minimal impact on existing code
that is used in libvirt so little regression possibility.
Further I discovered yesterday that we already have people
using this code as custom add-on patches, so I'd like to
help them by including it in 1.0.1
.gitignore | 5
bootstrap.conf | 1
cfg.mk | 9
libvirt.spec.in | 16
po/POTFILES.in | 4
run.in | 2
src/Makefile.am | 214 ++++-
src/internal.h | 22
src/libvirt_private.syms | 2
src/locking/libvirt_lockd.aug | 33
src/locking/lock_daemon.c | 1441 ++++++++++++++++++++++++++++++++++
src/locking/lock_daemon.h | 56 +
src/locking/lock_daemon_config.c | 193 ++++
src/locking/lock_daemon_config.h | 50 +
src/locking/lock_daemon_dispatch.c | 434 ++++++++++
src/locking/lock_daemon_dispatch.h | 31
src/locking/lock_driver_lockd.c | 834 +++++++++++++++++++
src/locking/lock_manager.c | 20
src/locking/lock_manager.h | 3
src/locking/lock_protocol.x | 95 ++
src/locking/lockd.conf | 68 +
src/locking/test_libvirt_lockd.aug.in | 7
src/locking/virtlockd.init.in | 93 ++
src/locking/virtlockd.service.in | 13
src/locking/virtlockd.socket.in | 8
src/locking/virtlockd.sysconf | 3
src/qemu/qemu.conf | 17
src/qemu/qemu_conf.c | 12
src/qemu/qemu_conf.h | 3
src/qemu/qemu_driver.c | 24
src/qemu/test_libvirtd_qemu.aug.in | 2
src/util/storage_file.c | 30
src/util/storage_file.h | 4
33 files changed, 3697 insertions(+), 52 deletions(-)
12 years
[libvirt] [PATCH] Change virCgroupGetAppRoot stub on non-Linux to avoid unused param warning
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Fully stub out the virCgroupGetAppRoot method as done with other
methods in the file, rather than just the body. This lets us
annotate the unused parameter to avoid a warning
Pushed as a Win32 build breaker fix
---
src/util/cgroup.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index f867fb7..8f3b8b7 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -974,14 +974,17 @@ int virCgroupForDriver(const char *name ATTRIBUTE_UNUSED,
*
* Returns 0 on success
*/
+#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
int virCgroupGetAppRoot(virCgroupPtr *group)
{
-#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
return virCgroupNew("/", group);
+}
#else
+int virCgroupGetAppRoot(virCgroupPtr *group ATTRIBUTE_UNUSED)
+{
return -ENXIO;
-#endif
}
+#endif
/**
* virCgroupForDomain:
--
1.7.11.7
12 years
[libvirt] [PATCH 00/12 v6] Unprivleged SG_IO support
by Osier Yang
As a result of RFC [1], this implements the unprivleged SG_IO
support.
v4 - v5:
* Per discussion in [2], this set uses a hash table to
store the shared disk's info. See 1/12 for more
details.
Osier Yang (12):
qemu: Add a hash table for the shared disks
docs: Add docs and rng schema for new XML cdbfilter
conf: Parse and format the new XML tag cdbfilter
util: Prepare helpers for unpriv_sgio setting
qemu: Manage disk's unpriv_sgio in domain lifecyle
qemu: Do not restore the sysfs unpriv_sgio if the disk is being
shared
qemu: Error out when domain starting if the cdbfilter setting
conflicts
qemu: Set unpriv_sgio when attaching disk
qemu: Restore unpriv_sgio when detaching disk
qemu: Error out if the shared disk conf conflicts with others when
attaching
qemu: Do not restore unpriv_sgio when detaching disk if it's still
shared
conf: Save disk's original unpriv_sgio state into status XML
docs/formatdomain.html.in | 13 ++-
docs/schemas/domaincommon.rng | 52 +++++--
src/conf/domain_conf.c | 93 ++++++++++---
src/conf/domain_conf.h | 11 ++
src/libvirt_private.syms | 4 +
src/qemu/qemu_conf.c | 60 ++++++++
src/qemu/qemu_conf.h | 22 +++
src/qemu/qemu_driver.c | 72 ++++++++++
src/qemu/qemu_process.c | 104 ++++++++++++++-
src/qemu/qemu_process.h | 3 +
src/util/util.c | 145 ++++++++++++++++++++
src/util/util.h | 8 +
...ml2argv-disk-scsi-lun-passthrough-cdbfilter.xml | 32 +++++
tests/qemuxml2xmltest.c | 1 +
14 files changed, 585 insertions(+), 35 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-lun-passthrough-cdbfilter.xml
[1] https://www.redhat.com/archives/libvir-list/2012-November/msg00988.html
[2] https://www.redhat.com/archives/libvir-list/2012-December/msg00325.html
Regards,
Osier
12 years
[libvirt] [PATCH v1 rebase 0/6] disable cgroup cpuset
by Hu Tao
This is merely a rebased version, so still tagged with v1.
The reason to disable cgroup cpuset by default is: currently,
sub-directories of cgroup cpuset won't be auto-updated if
cpu hot-plug happens. For example, if we now have 0-3,5-7 pcpus
online, the value of /sys/fs/cgroup/cpuset/libvirt/qemu/mydom/cpuset.cpus
is 0-3,5-7, then pcpu 4 is hot-plugged, but the value of cpuset.cpus
is still 0-3,5-7. This will cause a problem that we can't pin
to a hot-plugged pcpu.
Users can still enable cpuset by editing qemu.conf.
Hu Tao (6):
cgroup: Add a flag VIR_CGROUP_DISABLE_CPUSET
create cgroup controllers for driver according to config
create cgroup controllers for domain according to config
create cgroup controllers for vcpu according to config
create cgroup controllers for emulator according to config
disable cgroup cpuset by default
src/lxc/lxc_cgroup.c | 4 +-
src/lxc/lxc_driver.c | 22 +++++------
src/lxc/lxc_process.c | 4 +-
src/qemu/qemu.conf | 2 +-
src/qemu/qemu_cgroup.c | 15 ++++----
src/qemu/qemu_conf.c | 1 -
src/qemu/qemu_driver.c | 93 ++++++++++++++++++++++++++++++-----------------
src/qemu/qemu_hotplug.c | 9 +++--
src/qemu/qemu_migration.c | 2 +-
src/util/cgroup.c | 49 ++++++++++++++++++++-----
src/util/cgroup.h | 12 ++++--
11 files changed, 137 insertions(+), 76 deletions(-)
--
1.8.0.1.240.ge8a1f5a
12 years
[libvirt] [PATCH v1 0/6] disable cgroup cpuset
by Hu Tao
The reason to disable cgroup cpuset by default is: currently,
sub-directories of cgroup cpuset won't be auto-updated if
cpu hot-plug happens. For example, if we now have 0-3,5-7 pcpus
online, the value of /sys/fs/cgroup/cpuset/libvirt/qemu/mydom/cpuset.cpus
is 0-3,5-7, then pcpu 4 is hot-plugged, but the value of cpuset.cpus
is still 0-3,5-7. This will cause a problem that we can't pin
to a hot-plugged pcpu.
Users can still enable cpuset by editing qemu.conf.
Hu Tao (6):
cgroup: Add a flag VIR_CGROUP_DISABLE_CPUSET
create cgroup controllers for driver according to config
create cgroup controllers for domain according to config
create cgroup controllers for vcpu according to config
create cgroup controllers for emulator according to config
disable cgroup cpuset by default
src/lxc/lxc_cgroup.c | 4 +--
src/lxc/lxc_driver.c | 22 ++++++------
src/lxc/lxc_process.c | 4 +--
src/qemu/qemu.conf | 2 +-
src/qemu/qemu_cgroup.c | 15 ++++----
src/qemu/qemu_conf.c | 1 -
src/qemu/qemu_driver.c | 92 +++++++++++++++++++++++++++++------------------
src/qemu/qemu_hotplug.c | 9 +++--
src/qemu/qemu_migration.c | 2 +-
src/util/cgroup.c | 49 +++++++++++++++++++------
src/util/cgroup.h | 12 ++++---
11 files changed, 136 insertions(+), 76 deletions(-)
--
1.7.11.7
12 years