mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
qemu: Prepare for 'sd' card use together with blockdev
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@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
d876a93f05
commit
e664abb62e
@ -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;
|
||||
|
||||
|
@ -8212,6 +8212,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;
|
||||
|
||||
@ -8294,13 +8296,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;
|
||||
}
|
||||
@ -8358,7 +8361,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;
|
||||
|
||||
@ -13234,7 +13238,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 {
|
||||
|
@ -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'"),
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user