Use the qemu source string formatter to format the source string
correctly for remote and other storage instead of passing source->path
blindly.
---
src/qemu/qemu_driver.c | 3 ++-
src/qemu/qemu_hotplug.c | 12 +++++++++---
src/qemu/qemu_hotplug.h | 1 +
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index fc345d5..7088f19 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6665,7 +6665,8 @@ qemuDomainChangeDiskMediaLive(virConnectPtr conn,
newsrc = disk->src;
disk->src = NULL;
- ret = qemuDomainChangeEjectableMedia(driver, vm, orig_disk, newsrc, force);
+ ret = qemuDomainChangeEjectableMedia(driver, conn, vm,
+ orig_disk, newsrc, force);
/* 'disk' must not be accessed now - it has been freed.
* 'orig_disk' now points to the new disk, while 'dev_copy'
* now points to the old disk */
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 9ad06be..39907ab 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -138,6 +138,7 @@ qemuDomainPrepareDisk(virQEMUDriverPtr driver,
int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
+ virConnectPtr conn,
virDomainObjPtr vm,
virDomainDiskDefPtr disk,
virStorageSourcePtr newsrc,
@@ -148,6 +149,7 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData;
int retries = CHANGE_MEDIA_RETRIES;
const char *format = NULL;
+ char *sourcestr = NULL;
if (!disk->info.alias) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -197,7 +199,10 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
goto error;
}
- if (newsrc->path) {
+ if (!virStorageSourceIsLocalStorage(newsrc) || newsrc->path) {
+ if (qemuGetDriveSourceString(newsrc, conn, &sourcestr) < 0)
+ goto error;
+
if (virStorageSourceGetActualType(newsrc) != VIR_STORAGE_TYPE_DIR) {
if (newsrc->format > 0) {
format = virStorageFileFormatTypeToString(newsrc->format);
@@ -209,7 +214,7 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorChangeMedia(priv->mon,
driveAlias,
- newsrc->path,
+ sourcestr,
format);
qemuDomainObjExitMonitor(driver, vm);
}
@@ -228,6 +233,7 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
cleanup:
virStorageSourceFree(newsrc);
VIR_FREE(driveAlias);
+ VIR_FREE(sourcestr);
return ret;
error:
@@ -791,7 +797,7 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
newsrc = disk->src;
disk->src = NULL;
- ret = qemuDomainChangeEjectableMedia(driver, vm, orig_disk, newsrc, false);
+ ret = qemuDomainChangeEjectableMedia(driver, conn, vm, orig_disk, newsrc,
false);
/* 'newsrc' must not be accessed now - it has been free'd.
* 'orig_disk' now points to the new disk, while 'dev_copy'
* now points to the old disk */
diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h
index 5ce8f0a..1200e44 100644
--- a/src/qemu/qemu_hotplug.h
+++ b/src/qemu/qemu_hotplug.h
@@ -29,6 +29,7 @@
# include "domain_conf.h"
int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
+ virConnectPtr conn,
virDomainObjPtr vm,
virDomainDiskDefPtr disk,
virStorageSourcePtr newsrc,
--
2.0.2