提交 b57ca132 编写于 作者: P Peter Krempa

qemu: hotplug: Format proper source string for cdrom media change

Use the qemu source string formatter to format the source string
correctly for remote and other storage instead of passing source->path
blindly.
上级 1f39218e
...@@ -6681,7 +6681,8 @@ qemuDomainChangeDiskMediaLive(virConnectPtr conn, ...@@ -6681,7 +6681,8 @@ qemuDomainChangeDiskMediaLive(virConnectPtr conn,
newsrc = disk->src; newsrc = disk->src;
disk->src = NULL; 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. /* 'disk' must not be accessed now - it has been freed.
* 'orig_disk' now points to the new disk, while 'dev_copy' * 'orig_disk' now points to the new disk, while 'dev_copy'
* now points to the old disk */ * now points to the old disk */
......
...@@ -139,6 +139,7 @@ qemuDomainPrepareDisk(virQEMUDriverPtr driver, ...@@ -139,6 +139,7 @@ qemuDomainPrepareDisk(virQEMUDriverPtr driver,
int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
virConnectPtr conn,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainDiskDefPtr disk, virDomainDiskDefPtr disk,
virStorageSourcePtr newsrc, virStorageSourcePtr newsrc,
...@@ -149,6 +150,7 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, ...@@ -149,6 +150,7 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
int retries = CHANGE_MEDIA_RETRIES; int retries = CHANGE_MEDIA_RETRIES;
const char *format = NULL; const char *format = NULL;
char *sourcestr = NULL;
if (!disk->info.alias) { if (!disk->info.alias) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
...@@ -198,7 +200,10 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, ...@@ -198,7 +200,10 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
goto error; 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 (virStorageSourceGetActualType(newsrc) != VIR_STORAGE_TYPE_DIR) {
if (newsrc->format > 0) { if (newsrc->format > 0) {
format = virStorageFileFormatTypeToString(newsrc->format); format = virStorageFileFormatTypeToString(newsrc->format);
...@@ -210,7 +215,7 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, ...@@ -210,7 +215,7 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorChangeMedia(priv->mon, ret = qemuMonitorChangeMedia(priv->mon,
driveAlias, driveAlias,
newsrc->path, sourcestr,
format); format);
qemuDomainObjExitMonitor(driver, vm); qemuDomainObjExitMonitor(driver, vm);
} }
...@@ -229,6 +234,7 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, ...@@ -229,6 +234,7 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
cleanup: cleanup:
virStorageSourceFree(newsrc); virStorageSourceFree(newsrc);
VIR_FREE(driveAlias); VIR_FREE(driveAlias);
VIR_FREE(sourcestr);
return ret; return ret;
error: error:
...@@ -792,7 +798,7 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn, ...@@ -792,7 +798,7 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
newsrc = disk->src; newsrc = disk->src;
disk->src = NULL; 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. /* 'newsrc' must not be accessed now - it has been free'd.
* 'orig_disk' now points to the new disk, while 'dev_copy' * 'orig_disk' now points to the new disk, while 'dev_copy'
* now points to the old disk */ * now points to the old disk */
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
# include "domain_conf.h" # include "domain_conf.h"
int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
virConnectPtr conn,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainDiskDefPtr disk, virDomainDiskDefPtr disk,
virStorageSourcePtr newsrc, virStorageSourcePtr newsrc,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册