mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
qemu_hotplug: Prepare NVMe disks on hotplug
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
6edb4321b2
commit
430715604f
@ -11531,6 +11531,54 @@ typedef enum {
|
||||
} qemuDomainStorageSourceAccessFlags;
|
||||
|
||||
|
||||
static int
|
||||
qemuDomainStorageSourceAccessModifyNVMe(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
virStorageSourcePtr src,
|
||||
bool revoke)
|
||||
{
|
||||
bool revoke_maxmemlock = false;
|
||||
bool revoke_hostdev = false;
|
||||
int ret = -1;
|
||||
|
||||
if (!virStorageSourceChainHasNVMe(src))
|
||||
return 0;
|
||||
|
||||
VIR_DEBUG("Modifying access for a NVMe disk src=%p revoke=%d",
|
||||
src, revoke);
|
||||
|
||||
if (revoke) {
|
||||
revoke_maxmemlock = true;
|
||||
revoke_hostdev = true;
|
||||
ret = 0;
|
||||
goto revoke;
|
||||
}
|
||||
|
||||
if (qemuDomainAdjustMaxMemLock(vm, true) < 0)
|
||||
goto revoke;
|
||||
|
||||
revoke_maxmemlock = true;
|
||||
|
||||
if (qemuHostdevPrepareOneNVMeDisk(driver, vm->def->name, src) < 0)
|
||||
goto revoke;
|
||||
|
||||
revoke_hostdev = true;
|
||||
|
||||
return 0;
|
||||
|
||||
revoke:
|
||||
if (revoke_maxmemlock) {
|
||||
if (qemuDomainAdjustMaxMemLock(vm, false) < 0)
|
||||
VIR_WARN("Unable to change max memlock limit");
|
||||
}
|
||||
|
||||
if (revoke_hostdev)
|
||||
qemuHostdevReAttachOneNVMeDisk(driver, vm->def->name, src);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* qemuDomainStorageSourceAccessModify:
|
||||
* @driver: qemu driver struct
|
||||
@ -11562,6 +11610,7 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
|
||||
bool revoke_cgroup = false;
|
||||
bool revoke_label = false;
|
||||
bool revoke_namespace = false;
|
||||
bool revoke_nvme = false;
|
||||
bool revoke_lockspace = false;
|
||||
|
||||
VIR_DEBUG("src='%s' readonly=%d force_ro=%d force_rw=%d revoke=%d chain=%d",
|
||||
@ -11579,6 +11628,7 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
|
||||
revoke_cgroup = true;
|
||||
revoke_label = true;
|
||||
revoke_namespace = true;
|
||||
revoke_nvme = true;
|
||||
revoke_lockspace = true;
|
||||
ret = 0;
|
||||
goto revoke;
|
||||
@ -11589,6 +11639,11 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
|
||||
|
||||
revoke_lockspace = true;
|
||||
|
||||
if (qemuDomainStorageSourceAccessModifyNVMe(driver, vm, src, false) < 0)
|
||||
goto revoke;
|
||||
|
||||
revoke_nvme = true;
|
||||
|
||||
/* When modifying access of existing @src namespace does not need update */
|
||||
if (!(flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_MODIFY_ACCESS)) {
|
||||
if (qemuDomainNamespaceSetupDisk(vm, src) < 0)
|
||||
@ -11639,6 +11694,9 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
|
||||
VIR_WARN("Unable to remove /dev entry for %s", srcstr);
|
||||
}
|
||||
|
||||
if (revoke_nvme)
|
||||
qemuDomainStorageSourceAccessModifyNVMe(driver, vm, src, true);
|
||||
|
||||
if (revoke_lockspace) {
|
||||
if (virDomainLockImageDetach(driver->lockManager, vm, src) < 0)
|
||||
VIR_WARN("Unable to release lock on %s", srcstr);
|
||||
|
@ -212,6 +212,17 @@ qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDefPtr *hostdevs,
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
qemuHostdevPrepareOneNVMeDisk(virQEMUDriverPtr driver,
|
||||
const char *name,
|
||||
virStorageSourcePtr src)
|
||||
{
|
||||
return virHostdevPrepareOneNVMeDevice(driver->hostdevMgr,
|
||||
QEMU_DRIVER_NAME,
|
||||
name,
|
||||
src);
|
||||
}
|
||||
|
||||
int
|
||||
qemuHostdevPrepareNVMeDisks(virQEMUDriverPtr driver,
|
||||
const char *name,
|
||||
@ -369,6 +380,17 @@ qemuHostdevPrepareDomainDevices(virQEMUDriverPtr driver,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
qemuHostdevReAttachOneNVMeDisk(virQEMUDriverPtr driver,
|
||||
const char *name,
|
||||
virStorageSourcePtr src)
|
||||
{
|
||||
virHostdevReAttachOneNVMeDevice(driver->hostdevMgr,
|
||||
QEMU_DRIVER_NAME,
|
||||
name,
|
||||
src);
|
||||
}
|
||||
|
||||
void
|
||||
qemuHostdevReAttachNVMeDisks(virQEMUDriverPtr driver,
|
||||
const char *name,
|
||||
|
@ -41,6 +41,9 @@ int qemuHostdevUpdateActiveSCSIDevices(virQEMUDriverPtr driver,
|
||||
int qemuHostdevUpdateActiveDomainDevices(virQEMUDriverPtr driver,
|
||||
virDomainDefPtr def);
|
||||
|
||||
int qemuHostdevPrepareOneNVMeDisk(virQEMUDriverPtr driver,
|
||||
const char *name,
|
||||
virStorageSourcePtr src);
|
||||
int qemuHostdevPrepareNVMeDisks(virQEMUDriverPtr driver,
|
||||
const char *name,
|
||||
virDomainDiskDefPtr *disks,
|
||||
@ -74,6 +77,9 @@ int qemuHostdevPrepareDomainDevices(virQEMUDriverPtr driver,
|
||||
virQEMUCapsPtr qemuCaps,
|
||||
unsigned int flags);
|
||||
|
||||
void qemuHostdevReAttachOneNVMeDisk(virQEMUDriverPtr driver,
|
||||
const char *name,
|
||||
virStorageSourcePtr src);
|
||||
void qemuHostdevReAttachNVMeDisks(virQEMUDriverPtr driver,
|
||||
const char *name,
|
||||
virDomainDiskDefPtr *disks,
|
||||
|
Loading…
x
Reference in New Issue
Block a user