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 */
int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
+ virConnectPtr conn,
virDomainObjPtr vm,
virDomainDiskDefPtr disk,
virStorageSourcePtr newsrc,
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,
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);
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorChangeMedia(priv->mon,
driveAlias,
- newsrc->path,
+ sourcestr,
format);
qemuDomainObjExitMonitor(driver, vm);
}
cleanup:
virStorageSourceFree(newsrc);
VIR_FREE(driveAlias);
+ VIR_FREE(sourcestr);
return ret;
error:
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 */