mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
Introduce qemuDomainNamespaceMknodPath
Use this function in qemuDomainNamespaceSetup* functions which only require creating one device.
This commit is contained in:
parent
d3db304d2e
commit
323b9f72ef
@ -9971,6 +9971,16 @@ qemuDomainNamespaceMknodPaths(virDomainObjPtr vm,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuDomainNamespaceMknodPath(virDomainObjPtr vm,
|
||||
const char *path)
|
||||
{
|
||||
const char *paths[] = { path };
|
||||
|
||||
return qemuDomainNamespaceMknodPaths(vm, paths, 1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
||||
virDomainObjPtr vm,
|
||||
@ -10090,35 +10100,17 @@ qemuDomainNamespaceTeardownHostdev(virQEMUDriverPtr driver,
|
||||
|
||||
|
||||
int
|
||||
qemuDomainNamespaceSetupMemory(virQEMUDriverPtr driver,
|
||||
qemuDomainNamespaceSetupMemory(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
||||
virDomainObjPtr vm,
|
||||
virDomainMemoryDefPtr mem)
|
||||
{
|
||||
virQEMUDriverConfigPtr cfg = NULL;
|
||||
char **devMountsPath = NULL;
|
||||
size_t ndevMountsPath = 0;
|
||||
int ret = -1;
|
||||
|
||||
if (mem->model != VIR_DOMAIN_MEMORY_MODEL_NVDIMM)
|
||||
return 0;
|
||||
|
||||
if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
|
||||
return 0;
|
||||
if (qemuDomainNamespaceMknodPath(vm, mem->nvdimmPath) < 0)
|
||||
return -1;
|
||||
|
||||
cfg = virQEMUDriverGetConfig(driver);
|
||||
if (qemuDomainGetPreservedMounts(cfg, vm,
|
||||
&devMountsPath, NULL,
|
||||
&ndevMountsPath) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (qemuDomainAttachDeviceMknod(driver, vm, mem->nvdimmPath,
|
||||
devMountsPath, ndevMountsPath) < 0)
|
||||
goto cleanup;
|
||||
ret = 0;
|
||||
cleanup:
|
||||
virStringListFreeCount(devMountsPath, ndevMountsPath);
|
||||
virObjectUnref(cfg);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -10156,18 +10148,11 @@ qemuDomainNamespaceTeardownMemory(virQEMUDriverPtr driver,
|
||||
|
||||
|
||||
int
|
||||
qemuDomainNamespaceSetupChardev(virQEMUDriverPtr driver,
|
||||
qemuDomainNamespaceSetupChardev(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
||||
virDomainObjPtr vm,
|
||||
virDomainChrDefPtr chr)
|
||||
{
|
||||
virQEMUDriverConfigPtr cfg = NULL;
|
||||
char **devMountsPath = NULL;
|
||||
size_t ndevMountsPath = 0;
|
||||
const char *path;
|
||||
int ret = -1;
|
||||
|
||||
if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
|
||||
return 0;
|
||||
|
||||
if (!(path = virDomainChrSourceDefGetPath(chr->source)))
|
||||
return 0;
|
||||
@ -10177,22 +10162,10 @@ qemuDomainNamespaceSetupChardev(virQEMUDriverPtr driver,
|
||||
chr->source->data.nix.listen)
|
||||
return 0;
|
||||
|
||||
cfg = virQEMUDriverGetConfig(driver);
|
||||
if (qemuDomainGetPreservedMounts(cfg, vm,
|
||||
&devMountsPath, NULL,
|
||||
&ndevMountsPath) < 0)
|
||||
goto cleanup;
|
||||
if (qemuDomainNamespaceMknodPath(vm, path) < 0)
|
||||
return -1;
|
||||
|
||||
if (qemuDomainAttachDeviceMknod(driver,
|
||||
vm,
|
||||
path,
|
||||
devMountsPath, ndevMountsPath) < 0)
|
||||
goto cleanup;
|
||||
ret = 0;
|
||||
cleanup:
|
||||
virStringListFreeCount(devMountsPath, ndevMountsPath);
|
||||
virObjectUnref(cfg);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -10234,18 +10207,11 @@ qemuDomainNamespaceTeardownChardev(virQEMUDriverPtr driver,
|
||||
|
||||
|
||||
int
|
||||
qemuDomainNamespaceSetupRNG(virQEMUDriverPtr driver,
|
||||
qemuDomainNamespaceSetupRNG(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
||||
virDomainObjPtr vm,
|
||||
virDomainRNGDefPtr rng)
|
||||
{
|
||||
virQEMUDriverConfigPtr cfg = NULL;
|
||||
char **devMountsPath = NULL;
|
||||
size_t ndevMountsPath = 0;
|
||||
const char *path = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
|
||||
return 0;
|
||||
|
||||
switch ((virDomainRNGBackend) rng->backend) {
|
||||
case VIR_DOMAIN_RNG_BACKEND_RANDOM:
|
||||
@ -10254,26 +10220,13 @@ qemuDomainNamespaceSetupRNG(virQEMUDriverPtr driver,
|
||||
|
||||
case VIR_DOMAIN_RNG_BACKEND_EGD:
|
||||
case VIR_DOMAIN_RNG_BACKEND_LAST:
|
||||
ret = 0;
|
||||
goto cleanup;
|
||||
break;
|
||||
}
|
||||
|
||||
cfg = virQEMUDriverGetConfig(driver);
|
||||
if (qemuDomainGetPreservedMounts(cfg, vm,
|
||||
&devMountsPath, NULL,
|
||||
&ndevMountsPath) < 0)
|
||||
goto cleanup;
|
||||
if (path && qemuDomainNamespaceMknodPath(vm, path) < 0)
|
||||
return -1;
|
||||
|
||||
if (qemuDomainAttachDeviceMknod(driver,
|
||||
vm,
|
||||
path,
|
||||
devMountsPath, ndevMountsPath) < 0)
|
||||
goto cleanup;
|
||||
ret = 0;
|
||||
cleanup:
|
||||
virStringListFreeCount(devMountsPath, ndevMountsPath);
|
||||
virObjectUnref(cfg);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -10324,35 +10277,14 @@ int
|
||||
qemuDomainNamespaceSetupInput(virDomainObjPtr vm,
|
||||
virDomainInputDefPtr input)
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||
virQEMUDriverPtr driver = priv->driver;
|
||||
virQEMUDriverConfigPtr cfg = NULL;
|
||||
char **devMountsPath = NULL;
|
||||
size_t ndevMountsPath = 0;
|
||||
const char *path = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (!(path = virDomainInputDefGetPath(input)))
|
||||
return 0;
|
||||
|
||||
if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
|
||||
return 0;
|
||||
|
||||
cfg = virQEMUDriverGetConfig(driver);
|
||||
if (qemuDomainGetPreservedMounts(cfg, vm,
|
||||
&devMountsPath, NULL,
|
||||
&ndevMountsPath) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (qemuDomainAttachDeviceMknod(driver, vm, path,
|
||||
devMountsPath, ndevMountsPath) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
virStringListFreeCount(devMountsPath, ndevMountsPath);
|
||||
virObjectUnref(cfg);
|
||||
return ret;
|
||||
if (path && qemuDomainNamespaceMknodPath(vm, path) < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user