SD cards need to be instantiated via -drive if=sd. This means that all cases where we use the blockdev path need to be special-cased for SD cards. Note that at this point QEMU_CAPS_BLOCKDEV is still cleared if the VM config has a SD card. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_command.c | 3 ++- src/qemu/qemu_domain.c | 13 +++++++++---- src/qemu/qemu_driver.c | 3 ++- src/qemu/qemu_hotplug.c | 3 ++- src/qemu/qemu_process.c | 6 +++++- src/qemu/qemu_validate.c | 4 +++- 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 07669ded44..5b803f106b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2089,7 +2089,8 @@ qemuBuildDiskSourceCommandLine(virCommandPtr cmd, g_autofree char *copyOnReadPropsStr = NULL; size_t i; - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV) && + !qemuDiskBusIsSD(disk->bus)) { if (virStorageSourceIsEmpty(disk->src)) return 0; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 395cc3daee..0c122f300d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8216,6 +8216,8 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, virStorageSourcePtr src; /* iterator for the backing chain declared in XML */ virStorageSourcePtr n; /* iterator for the backing chain detected from disk */ qemuDomainObjPrivatePtr priv = vm->privateData; + bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); + bool isSD = qemuDiskBusIsSD(disk->bus); uid_t uid; gid_t gid; @@ -8298,13 +8300,14 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, if (n->format == VIR_STORAGE_FILE_ISO) n->format = VIR_STORAGE_FILE_RAW; - if (qemuDomainValidateStorageSource(n, priv->qemuCaps, false) < 0) + /* mask-out blockdev for 'sd' disks */ + if (qemuDomainValidateStorageSource(n, priv->qemuCaps, isSD) < 0) return -1; qemuDomainPrepareStorageSourceConfig(n, cfg, priv->qemuCaps); qemuDomainPrepareDiskSourceData(disk, n); - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV) && + if (blockdev && !isSD && qemuDomainPrepareStorageSourceBlockdev(disk, n, priv, cfg) < 0) return -1; } @@ -8362,7 +8365,8 @@ qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk, { *backendAlias = NULL; - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV) || + qemuDiskBusIsSD(disk->bus)) { if (!(*backendAlias = qemuAliasDiskDriveFromDisk(disk))) return -1; @@ -13238,7 +13242,8 @@ qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk, disk->src->format = VIR_STORAGE_FILE_RAW; } - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) { + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV) && + !qemuDiskBusIsSD(disk->bus)) { if (qemuDomainPrepareDiskSourceBlockdev(disk, priv, cfg) < 0) return -1; } else { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1617f79d34..63b4a49c3c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10808,7 +10808,8 @@ qemuDomainBlockResize(virDomainPtr dom, disk->src->format == VIR_STORAGE_FILE_QED) size = VIR_ROUND_UP(size, 512); - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) { + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV) && + !qemuDiskBusIsSD(disk->bus)) { if (virStorageSourceIsEmpty(disk->src) || disk->src->readonly) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("can't resize empty or readonly disk '%s'"), diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index f1b2fbb1a8..ab5a7aef84 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4270,7 +4270,8 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, disk->info.alias, vm, vm->def->name); - if (blockdev) { + if (blockdev && + !qemuDiskBusIsSD(disk->bus)) { corAlias = g_strdup(diskPriv->nodeCopyOnRead); if (diskPriv->blockjob) { diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index fe2ac2dcfe..b1751d4b52 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6405,7 +6405,7 @@ qemuProcessPrepareHostStorage(virQEMUDriverPtr driver, continue; /* backing chain needs to be redetected if we aren't using blockdev */ - if (!blockdev) + if (!blockdev || qemuDiskBusIsSD(disk->bus)) virStorageSourceBackingStoreClear(disk->src); /* @@ -6634,6 +6634,10 @@ qemuProcessSetupDiskThrottlingBlockdev(virQEMUDriverPtr driver, virDomainDiskDefPtr disk = vm->def->disks[i]; qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); + /* sd-cards are instantiated via -drive */ + if (qemuDiskBusIsSD(disk->bus)) + continue; + if (!qemuDiskConfigBlkdeviotuneEnabled(disk)) continue; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index f49181b639..2cde678ca0 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2259,6 +2259,7 @@ qemuValidateDomainDeviceDefDisk(const virDomainDiskDef *disk, virQEMUCapsPtr qemuCaps) { const char *driverName = virDomainDiskGetDriver(disk); + bool isSD = qemuDiskBusIsSD(disk->bus); virStorageSourcePtr n; int idx; int partition; @@ -2298,7 +2299,8 @@ qemuValidateDomainDeviceDefDisk(const virDomainDiskDef *disk, } for (n = disk->src; virStorageSourceIsBacking(n); n = n->backingStore) { - if (qemuDomainValidateStorageSource(n, qemuCaps, false) < 0) + /* blockdev support is masked out for 'sd' disks */ + if (qemuDomainValidateStorageSource(n, qemuCaps, isSD) < 0) return -1; } -- 2.26.2