[libvirt] [PATCH]qemu:sheepdog Permit qemu to access sheepdog volume on sheepdog's pool
by joel SIMOES
From: Joël Simoes <jsimoes@jsimoes>
---
src/qemu/qemu_conf.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 62 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 4378791..2d2f428 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1185,6 +1185,56 @@ int qemuDriverAllocateID(virQEMUDriverPtr driver)
return virAtomicIntInc(&driver->nextvmid);
}
+
+static int
+qemuAddSheepPoolSourceHost(virDomainDiskDefPtr def,
+ virStoragePoolDefPtr pooldef)
+{
+ int ret = -1;
+ char **tokens = NULL;
+
+ /* Only support one host */
+ if (pooldef->source.nhost != 1) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Expected exactly 1 host for the storage pool"));
+ goto cleanup;
+ }
+
+ /* iscsi pool only supports one host */
+ def->nhosts = 1;
+
+ if (VIR_ALLOC_N(def->hosts, def->nhosts) < 0)
+ goto cleanup;
+
+ if (VIR_STRDUP(def->hosts[0].name, pooldef->source.hosts[0].name) < 0)
+ goto cleanup;
+
+ if (virAsprintf(&def->hosts[0].port, "%d",
+ pooldef->source.hosts[0].port ?
+ pooldef->source.hosts[0].port :
+ 7000) < 0)
+ goto cleanup;
+
+
+
+
+
+ /* Storage pool have not supported these 2 attributes yet,
+ * use the defaults.
+ */
+ def->hosts[0].transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP;
+ def->hosts[0].socket = NULL;
+
+
+ def->protocol = VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG;
+
+ ret = 0;
+
+cleanup:
+ virStringFreeList(tokens);
+ return ret;
+}
+
static int
qemuAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
virStoragePoolDefPtr pooldef)
@@ -1353,10 +1403,10 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
def->srcpool->pooltype = pooldef->type;
def->srcpool->voltype = info.type;
- if (def->srcpool->mode && pooldef->type != VIR_STORAGE_POOL_ISCSI) {
+ if ((def->srcpool->mode && pooldef->type != VIR_STORAGE_POOL_ISCSI) || (def->srcpool->mode != VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DIRECT && pooldef->type == VIR_STORAGE_POOL_SHEEPDOG ) ) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("disk source mode is only valid when "
- "storage pool is of iscsi type"));
+ "storage pool is of iscsi type or only direct for sheepdog "));
goto cleanup;
}
@@ -1439,9 +1489,17 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
}
break;
- case VIR_STORAGE_POOL_MPATH:
- case VIR_STORAGE_POOL_RBD:
case VIR_STORAGE_POOL_SHEEPDOG:
+ def->srcpool->actualtype = VIR_DOMAIN_DISK_TYPE_NETWORK;
+ // force direct mode
+ def->srcpool->mode = VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DIRECT;
+ def->protocol = VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG;
+ def->src = virStorageVolGetPath(vol);
+
+ qemuAddSheepPoolSourceHost(def, pooldef);
+ break;
+ case VIR_STORAGE_POOL_MPATH:
+ case VIR_STORAGE_POOL_RBD:
case VIR_STORAGE_POOL_GLUSTER:
case VIR_STORAGE_POOL_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--
1.8.3.2
10 years, 10 months
[libvirt] [PATCH]qemu:sheepdog Permit qemu to access sheepdog volume on sheepdog's pool
by joel SIMOES
From: Joel SIMOES <joel.simoes(a)laposte.net>
---
src/qemu/qemu_conf.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 62 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 4378791..2d2f428 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1185,6 +1185,56 @@ int qemuDriverAllocateID(virQEMUDriverPtr driver)
return virAtomicIntInc(&driver->nextvmid);
}
+
+static int
+qemuAddSheepPoolSourceHost(virDomainDiskDefPtr def,
+ virStoragePoolDefPtr pooldef)
+{
+ int ret = -1;
+ char **tokens = NULL;
+
+ /* Only support one host */
+ if (pooldef->source.nhost != 1) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Expected exactly 1 host for the storage pool"));
+ goto cleanup;
+ }
+
+ /* iscsi pool only supports one host */
+ def->nhosts = 1;
+
+ if (VIR_ALLOC_N(def->hosts, def->nhosts) < 0)
+ goto cleanup;
+
+ if (VIR_STRDUP(def->hosts[0].name, pooldef->source.hosts[0].name) < 0)
+ goto cleanup;
+
+ if (virAsprintf(&def->hosts[0].port, "%d",
+ pooldef->source.hosts[0].port ?
+ pooldef->source.hosts[0].port :
+ 7000) < 0)
+ goto cleanup;
+
+
+
+
+
+ /* Storage pool have not supported these 2 attributes yet,
+ * use the defaults.
+ */
+ def->hosts[0].transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP;
+ def->hosts[0].socket = NULL;
+
+
+ def->protocol = VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG;
+
+ ret = 0;
+
+cleanup:
+ virStringFreeList(tokens);
+ return ret;
+}
+
static int
qemuAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
virStoragePoolDefPtr pooldef)
@@ -1353,10 +1403,10 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
def->srcpool->pooltype = pooldef->type;
def->srcpool->voltype = info.type;
- if (def->srcpool->mode && pooldef->type != VIR_STORAGE_POOL_ISCSI) {
+ if ((def->srcpool->mode && pooldef->type != VIR_STORAGE_POOL_ISCSI) || (def->srcpool->mode != VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DIRECT && pooldef->type == VIR_STORAGE_POOL_SHEEPDOG ) ) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("disk source mode is only valid when "
- "storage pool is of iscsi type"));
+ "storage pool is of iscsi type or only direct for sheepdog "));
goto cleanup;
}
@@ -1439,9 +1489,17 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
}
break;
- case VIR_STORAGE_POOL_MPATH:
- case VIR_STORAGE_POOL_RBD:
case VIR_STORAGE_POOL_SHEEPDOG:
+ def->srcpool->actualtype = VIR_DOMAIN_DISK_TYPE_NETWORK;
+ // force direct mode
+ def->srcpool->mode = VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DIRECT;
+ def->protocol = VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG;
+ def->src = virStorageVolGetPath(vol);
+
+ qemuAddSheepPoolSourceHost(def, pooldef);
+ break;
+ case VIR_STORAGE_POOL_MPATH:
+ case VIR_STORAGE_POOL_RBD:
case VIR_STORAGE_POOL_GLUSTER:
case VIR_STORAGE_POOL_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--
1.8.3.2
10 years, 10 months
[libvirt] [PATCHv2 0/2] Add a test for linuxNodeGetCPUStats
by Ján Tomko
v1: https://www.redhat.com/archives/libvir-list/2014-January/msg00951.html
v2:
use ticks instead of nsecs in test data
Ján Tomko (2):
Add test for linuxNodeGetCPUStats
Simplify linuxNodeGetCPUStats
src/libvirt_linux.syms | 1 +
src/nodeinfo.c | 83 +++++++--------
tests/nodeinfodata/linux-cpustat-24cpu.out | 150 ++++++++++++++++++++++++++++
tests/nodeinfodata/linux-cpustat-24cpu.stat | 25 +++++
tests/nodeinfotest.c | 131 ++++++++++++++++++++++++
5 files changed, 342 insertions(+), 48 deletions(-)
create mode 100644 tests/nodeinfodata/linux-cpustat-24cpu.out
create mode 100644 tests/nodeinfodata/linux-cpustat-24cpu.stat
--
1.8.3.2
10 years, 10 months
[libvirt] [PATCH] qemu: Avoid crash in qemuDiskGetActualType
by Peter Krempa
Libvirtd would crash if a domain contained an empty cdrom drive of
type='volume' as the disk def->srcpool member would be dereferenced. Fix
it by checking if the source pool is present before dereferencing it.
Also alter tests to catch this issue in the future.
Reported by: Kevin Shanahan
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1056328
---
src/qemu/qemu_conf.c | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.args | 2 ++
tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.xml | 6 ++++++
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 4378791..ac53f6d 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1302,7 +1302,7 @@ cleanup:
int
qemuDiskGetActualType(virDomainDiskDefPtr def)
{
- if (def->type == VIR_DOMAIN_DISK_TYPE_VOLUME)
+ if (def->type == VIR_DOMAIN_DISK_TYPE_VOLUME && def->srcpool)
return def->srcpool->actualtype;
return def->type;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.args
index da87ad9..6b409b7 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.args
@@ -3,6 +3,8 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb -drive \
file=/some/block/device/cdrom,if=none,media=cdrom,id=drive-ide0-0-1 -device \
ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 -drive \
+if=none,media=cdrom,id=drive-ide0-1-0 -device \
+ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -drive \
file=/tmp/idedisk.img,if=none,id=drive-ide0-0-2 -device \
ide-drive,bus=ide.0,unit=2,drive=drive-ide0-0-2,id=ide0-0-2 -device \
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.xml
index 6ca5cf7..e96f76e 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.xml
@@ -24,6 +24,12 @@
<readonly/>
<address type='drive' controller='0' bus='0' target='0' unit='1'/>
</disk>
+ <disk type='volume' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+ </disk>
<disk type='file' device='disk'>
<source file='/tmp/idedisk.img'/>
<target dev='hdc' bus='ide'/>
--
1.8.5.3
10 years, 10 months
[libvirt] [PATCH 0/3] Doc fixes
by Osier Yang
*** BLURB HERE ***
Osier Yang (3):
virsh: Fix the string breaking style
Doc: Improve the document for nodesuspend
Doc: Add "note" for node-memory-tune
tools/virsh-host.c | 6 +++---
tools/virsh.pod | 16 +++++++++++-----
2 files changed, 14 insertions(+), 8 deletions(-)
--
1.8.1.4
10 years, 10 months
[libvirt] [PATCH v2] virtlockd: make re-exec more robust
by Michael Chapman
- Use $XDG_RUNTIME_DIR for re-exec state file when running unprivileged.
- argv[0] may not contain a full path to the binary, however it should
contain something that can be looked up in the PATH. Use execvp() to
do path lookup on re-exec.
- As per list discussion [1], ignore --daemon on re-exec.
[1] https://www.redhat.com/archives/libvir-list/2013-December/msg00514.html
Signed-off-by: Michael Chapman <mike(a)very.puzzling.org>
---
src/locking/lock_daemon.c | 128 ++++++++++++++++++++++++++++++++++------------
1 file changed, 94 insertions(+), 34 deletions(-)
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index a6be43c..b405e3a 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -925,7 +925,41 @@ error:
}
-#define VIR_LOCK_DAEMON_RESTART_EXEC_FILE LOCALSTATEDIR "/run/virtlockd-restart-exec.json"
+static int
+virLockDaemonExecRestartStatePath(bool privileged,
+ char **state_file)
+{
+ if (privileged) {
+ if (VIR_STRDUP(*state_file, LOCALSTATEDIR "/run/virtlockd-restart-exec.json") < 0)
+ goto error;
+ } else {
+ char *rundir = NULL;
+ mode_t old_umask;
+
+ if (!(rundir = virGetUserRuntimeDirectory()))
+ goto error;
+
+ old_umask = umask(077);
+ if (virFileMakePath(rundir) < 0) {
+ umask(old_umask);
+ goto error;
+ }
+ umask(old_umask);
+
+ if (virAsprintf(state_file, "%s/virtlockd-restart-exec.json", rundir) < 0) {
+ VIR_FREE(rundir);
+ goto error;
+ }
+
+ VIR_FREE(rundir);
+ }
+
+ return 0;
+
+error:
+ return -1;
+}
+
static char *
virLockDaemonGetExecRestartMagic(void)
@@ -938,7 +972,10 @@ virLockDaemonGetExecRestartMagic(void)
static int
-virLockDaemonPostExecRestart(bool privileged)
+virLockDaemonPostExecRestart(const char *state_file,
+ const char *pid_file,
+ int *pid_file_fd,
+ bool privileged)
{
const char *gotmagic;
char *wantmagic = NULL;
@@ -948,14 +985,14 @@ virLockDaemonPostExecRestart(bool privileged)
VIR_DEBUG("Running post-restart exec");
- if (!virFileExists(VIR_LOCK_DAEMON_RESTART_EXEC_FILE)) {
- VIR_DEBUG("No restart file %s present",
- VIR_LOCK_DAEMON_RESTART_EXEC_FILE);
+ if (!virFileExists(state_file)) {
+ VIR_DEBUG("No restart state file %s present",
+ state_file);
ret = 0;
goto cleanup;
}
- if (virFileReadAll(VIR_LOCK_DAEMON_RESTART_EXEC_FILE,
+ if (virFileReadAll(state_file,
1024 * 1024 * 10, /* 10 MB */
&state) < 0)
goto cleanup;
@@ -982,13 +1019,18 @@ virLockDaemonPostExecRestart(bool privileged)
goto cleanup;
}
+ /* Re-claim PID file now as we will not be daemonizing */
+ if (pid_file &&
+ (*pid_file_fd = virPidFileAcquirePath(pid_file, getpid())) < 0)
+ goto cleanup;
+
if (!(lockDaemon = virLockDaemonNewPostExecRestart(object, privileged)))
goto cleanup;
ret = 1;
cleanup:
- unlink(VIR_LOCK_DAEMON_RESTART_EXEC_FILE);
+ unlink(state_file);
VIR_FREE(wantmagic);
VIR_FREE(state);
virJSONValueFree(object);
@@ -997,7 +1039,8 @@ cleanup:
static int
-virLockDaemonPreExecRestart(virNetServerPtr srv,
+virLockDaemonPreExecRestart(const char *state_file,
+ virNetServerPtr srv,
char **argv)
{
virJSONValuePtr child;
@@ -1065,15 +1108,15 @@ virLockDaemonPreExecRestart(virNetServerPtr srv,
VIR_DEBUG("Saving state %s", state);
- if (virFileWriteStr(VIR_LOCK_DAEMON_RESTART_EXEC_FILE,
+ if (virFileWriteStr(state_file,
state, 0700) < 0) {
virReportSystemError(errno,
_("Unable to save state file %s"),
- VIR_LOCK_DAEMON_RESTART_EXEC_FILE);
+ state_file);
goto cleanup;
}
- if (execv(argv[0], argv) < 0) {
+ if (execvp(argv[0], argv) < 0) {
virReportSystemError(errno, "%s",
_("Unable to restart self"));
goto cleanup;
@@ -1153,6 +1196,7 @@ int main(int argc, char **argv) {
char *pid_file = NULL;
int pid_file_fd = -1;
char *sock_file = NULL;
+ char *state_file = NULL;
bool implicit_conf = false;
mode_t old_umask;
bool privileged = false;
@@ -1276,21 +1320,13 @@ int main(int argc, char **argv) {
VIR_DEBUG("Decided on socket paths '%s'",
sock_file);
- if (godaemon) {
- char ebuf[1024];
-
- if (chdir("/") < 0) {
- VIR_ERROR(_("cannot change to root directory: %s"),
- virStrerror(errno, ebuf, sizeof(ebuf)));
- goto cleanup;
- }
-
- if ((statuswrite = virLockDaemonForkIntoBackground(argv[0])) < 0) {
- VIR_ERROR(_("Failed to fork as daemon: %s"),
- virStrerror(errno, ebuf, sizeof(ebuf)));
- goto cleanup;
- }
+ if (virLockDaemonExecRestartStatePath(privileged,
+ &state_file) < 0) {
+ VIR_ERROR(_("Can't determine restart state file path"));
+ exit(EXIT_FAILURE);
}
+ VIR_DEBUG("Decided on restart state file path '%s'",
+ state_file);
/* Ensure the rundir exists (on tmpfs on some systems) */
if (privileged) {
@@ -1317,20 +1353,41 @@ int main(int argc, char **argv) {
}
umask(old_umask);
- /* If we have a pidfile set, claim it now, exiting if already taken */
- if ((pid_file_fd = virPidFileAcquirePath(pid_file, getpid())) < 0) {
- ret = VIR_LOCK_DAEMON_ERR_PIDFILE;
- goto cleanup;
- }
-
- if ((rv = virLockDaemonPostExecRestart(privileged)) < 0) {
+ if ((rv = virLockDaemonPostExecRestart(state_file,
+ pid_file,
+ &pid_file_fd,
+ privileged)) < 0) {
ret = VIR_LOCK_DAEMON_ERR_INIT;
goto cleanup;
}
/* rv == 1, means we setup everything from saved state,
- * so we only setup stuff from scratch if rv == 0 */
+ * so only (possibly) daemonize and setup stuff from
+ * scratch if rv == 0
+ */
if (rv == 0) {
+ if (godaemon) {
+ char ebuf[1024];
+
+ if (chdir("/") < 0) {
+ VIR_ERROR(_("cannot change to root directory: %s"),
+ virStrerror(errno, ebuf, sizeof(ebuf)));
+ goto cleanup;
+ }
+
+ if ((statuswrite = virLockDaemonForkIntoBackground(argv[0])) < 0) {
+ VIR_ERROR(_("Failed to fork as daemon: %s"),
+ virStrerror(errno, ebuf, sizeof(ebuf)));
+ goto cleanup;
+ }
+ }
+
+ /* If we have a pidfile set, claim it now, exiting if already taken */
+ if ((pid_file_fd = virPidFileAcquirePath(pid_file, getpid())) < 0) {
+ ret = VIR_LOCK_DAEMON_ERR_PIDFILE;
+ goto cleanup;
+ }
+
if (!(lockDaemon = virLockDaemonNew(config, privileged))) {
ret = VIR_LOCK_DAEMON_ERR_INIT;
goto cleanup;
@@ -1388,7 +1445,9 @@ int main(int argc, char **argv) {
virNetServerRun(lockDaemon->srv);
if (execRestart &&
- virLockDaemonPreExecRestart(lockDaemon->srv, argv) < 0)
+ virLockDaemonPreExecRestart(state_file,
+ lockDaemon->srv,
+ argv) < 0)
ret = VIR_LOCK_DAEMON_ERR_REEXEC;
else
ret = 0;
@@ -1410,6 +1469,7 @@ cleanup:
virPidFileReleasePath(pid_file, pid_file_fd);
VIR_FREE(pid_file);
VIR_FREE(sock_file);
+ VIR_FREE(state_file);
VIR_FREE(run_dir);
return ret;
--
1.8.4.2
10 years, 10 months
[libvirt] [PATCH] docs: refer to the correct event ID for DomainEventIOErrorReasonCallback
by Claudio Bley
s/_ID_IO_ERROR/_ID_IO_ERROR_REASON/
Signed-off-by: Claudio Bley <cbley(a)av-test.de>
---
Pushed under the trivial rule.
include/libvirt/libvirt.h.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index a448411..47a896b 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -4664,7 +4664,7 @@ typedef void (*virConnectDomainEventIOErrorCallback)(virConnectPtr conn,
* @opaque: application specified data
*
* The callback signature to use when registering for an event of type
- * VIR_DOMAIN_EVENT_ID_IO_ERROR with virConnectDomainEventRegisterAny()
+ * VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON with virConnectDomainEventRegisterAny()
*
*/
typedef void (*virConnectDomainEventIOErrorReasonCallback)(virConnectPtr conn,
--
1.7.9.5
10 years, 10 months
[libvirt] [PATCH 0/2] Add a test for linuxNodeGetCPUStats
by Ján Tomko
Ján Tomko (2):
Add test for linuxNodeGetCPUStats
Simplify linuxNodeGetCPUStats
src/libvirt_linux.syms | 1 +
src/nodeinfo.c | 83 +++++++--------
tests/nodeinfodata/linux-cpustat-24cpu.out | 150 ++++++++++++++++++++++++++++
tests/nodeinfodata/linux-cpustat-24cpu.stat | 25 +++++
tests/nodeinfotest.c | 128 ++++++++++++++++++++++++
5 files changed, 339 insertions(+), 48 deletions(-)
create mode 100644 tests/nodeinfodata/linux-cpustat-24cpu.out
create mode 100644 tests/nodeinfodata/linux-cpustat-24cpu.stat
--
1.8.3.2
10 years, 10 months
[libvirt] [PATCH] qemu: snapshot: Forbid snapshots when backing is a scsi passthrough disk
by Peter Krempa
https://bugzilla.redhat.com/show_bug.cgi?id=1034993
SCSI passthrough disks (<disk .. device="lun">) can't be used as backing
for snapshots. Currently with upstream qemu the vm crashes on such
attempt.
This patch adds a early check to catch an attempt to do such a snapshot
and rejects it right away. qemu will fix the issue but this will let us
control the error message.
---
Notes:
You need a domain with a similar disk config to test this patch:
<disk type='block' device='lun'>
<driver name='qemu' type='raw'/>
<source dev='/dev/disk/by-path/ip-192.168.122.223:3260-iscsi-iqn.2011-03.org.example.istgt:test-lun-0'/>
<target dev='sda' bus='scsi'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='scsi' index='0' model='virtio-scsi'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</controller>
src/qemu/qemu_driver.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b101d77..bc29714 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12206,7 +12206,7 @@ endjob:
}
static int
-qemuDomainSnapshotPrepareDiskExternalBacking(virDomainDiskDefPtr disk)
+qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
{
int actualType = qemuDiskGetActualType(disk);
@@ -12250,6 +12250,23 @@ qemuDomainSnapshotPrepareDiskExternalBacking(virDomainDiskDefPtr disk)
static int
+qemuDomainSnapshotPrepareDiskExternalBackingActive(virDomainDiskDefPtr disk)
+{
+ int actualType = qemuDiskGetActualType(disk);
+
+ if (actualType == VIR_DOMAIN_DISK_TYPE_BLOCK &&
+ disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("external active snapshots are not supported on scsi "
+ "passthrough devices"));
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static int
qemuDomainSnapshotPrepareDiskExternalOverlayActive(virDomainSnapshotDiskDefPtr disk)
{
int actualType = qemuSnapshotDiskGetActualType(disk);
@@ -12315,12 +12332,15 @@ qemuDomainSnapshotPrepareDiskExternal(virConnectPtr conn,
if (qemuTranslateDiskSourcePool(conn, disk) < 0)
return -1;
- if (qemuDomainSnapshotPrepareDiskExternalBacking(disk) < 0)
+ if (qemuDomainSnapshotPrepareDiskExternalBackingInactive(disk) < 0)
return -1;
if (qemuDomainSnapshotPrepareDiskExternalOverlayInactive(snapdisk) < 0)
return -1;
} else {
+ if (qemuDomainSnapshotPrepareDiskExternalBackingActive(disk) < 0)
+ return -1;
+
if (qemuDomainSnapshotPrepareDiskExternalOverlayActive(snapdisk) < 0)
return -1;
}
--
1.8.5.3
10 years, 10 months
[libvirt] [vmware] Fix VMware driver version checking on Linux
by ryan woodsmall
Recent changes to the VMware driver allow for VMware Fusion version checking on OS X. It looks like the version checking on Linux for VMware Workstation and Player could possibly be broken by the changes. The version check in vmware_conf.c bundled STDOUT and STDERR into a common buffer; when/if something is printed to STDERR, at least on Player, version checking fails.
This example output causes the version check to fail on a RHEL6-based Linux install:
**
[ryan@os-sl6-controller ~]$ vmplayer -v
Gtk-Message: Failed to load module "canberra-gtk-module": libcanberra-gtk-module.so: cannot open shared object file: No such file or directory
VMware Player 6.0.1 build-1379776
[ryan@os-sl6-controller ~]$ virsh -c vmwareplayer:///session
error: failed to connect to the hypervisor
error: internal error: failed to parse VMware Player version
**
This patch bundles STDERR into the checked buffer only with the VMware Fusion driver, allowing the VMware Player version check to succeed on Linux even with the above warning. It looks like there's still an issue (see below) but virsh now starts at least.
**
[ryan@os-sl6-controller ~]$ virsh -c vmwareplayer:///session
Welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
virsh # version
Compiled against library: libvirt 1.2.1
Using library: libvirt 1.2.1
Using API: VMware 1.2.1
Cannot extract running VMware hypervisor version
**
This is virsh running against VMware Player 6.0.1 on Linux x86_64. I have not tested on OS X since I don't have a license for VMware Fusion. Thanks everyone!
-r
diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
index c96bd62..502d5c9 100644
--- a/src/vmware/vmware_conf.c
+++ b/src/vmware/vmware_conf.c
@@ -293,7 +293,8 @@ vmwareExtractVersion(struct vmware_driver *driver)
cmd = virCommandNewArgList(bin, "-v", NULL);
virCommandSetOutputBuffer(cmd, &outbuf);
- virCommandSetErrorBuffer(cmd, &outbuf);
+ if (driver->type == VMWARE_DRIVER_FUSION)
+ virCommandSetErrorBuffer(cmd, &outbuf);
if (virCommandRun(cmd, NULL) < 0)
goto cleanup;
10 years, 10 months