mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
qemu, lxc: move NodeDeviceGetPCIInfo() function to domain_driver.c
libxlNodeDeviceGetPCIInfo() and qemuNodeDeviceGetPCIInfo() are equal. Let's move the logic to a new virDomainDriverNodeDeviceGetPCIInfo() info to be used by libxl_driver.c and qemu_driver.c. Reviewed-by: Laine Stump <laine@redhat.com> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
03f9c17805
commit
28657b8001
@ -336,3 +336,35 @@ virDomainDriverSetupPersistentDefBlkioParams(virDomainDefPtr persistentDef,
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
virDomainDriverNodeDeviceGetPCIInfo(virNodeDeviceDefPtr def,
|
||||||
|
unsigned *domain,
|
||||||
|
unsigned *bus,
|
||||||
|
unsigned *slot,
|
||||||
|
unsigned *function)
|
||||||
|
{
|
||||||
|
virNodeDevCapsDefPtr cap;
|
||||||
|
|
||||||
|
cap = def->caps;
|
||||||
|
while (cap) {
|
||||||
|
if (cap->data.type == VIR_NODE_DEV_CAP_PCI_DEV) {
|
||||||
|
*domain = cap->data.pci_dev.domain;
|
||||||
|
*bus = cap->data.pci_dev.bus;
|
||||||
|
*slot = cap->data.pci_dev.slot;
|
||||||
|
*function = cap->data.pci_dev.function;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cap = cap->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cap) {
|
||||||
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
|
_("device %s is not a PCI device"), def->name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "domain_conf.h"
|
#include "domain_conf.h"
|
||||||
|
#include "node_device_conf.h"
|
||||||
|
|
||||||
char *
|
char *
|
||||||
virDomainDriverGenerateRootHash(const char *drivername,
|
virDomainDriverGenerateRootHash(const char *drivername,
|
||||||
@ -45,3 +46,9 @@ int virDomainDriverParseBlkioDeviceStr(char *blkioDeviceStr, const char *type,
|
|||||||
int virDomainDriverSetupPersistentDefBlkioParams(virDomainDefPtr persistentDef,
|
int virDomainDriverSetupPersistentDefBlkioParams(virDomainDefPtr persistentDef,
|
||||||
virTypedParameterPtr params,
|
virTypedParameterPtr params,
|
||||||
int nparams);
|
int nparams);
|
||||||
|
|
||||||
|
int virDomainDriverNodeDeviceGetPCIInfo(virNodeDeviceDefPtr def,
|
||||||
|
unsigned *domain,
|
||||||
|
unsigned *bus,
|
||||||
|
unsigned *slot,
|
||||||
|
unsigned *function);
|
||||||
|
@ -1503,6 +1503,7 @@ virDomainCgroupSetupMemtune;
|
|||||||
virDomainDriverGenerateMachineName;
|
virDomainDriverGenerateMachineName;
|
||||||
virDomainDriverGenerateRootHash;
|
virDomainDriverGenerateRootHash;
|
||||||
virDomainDriverMergeBlkioDevice;
|
virDomainDriverMergeBlkioDevice;
|
||||||
|
virDomainDriverNodeDeviceGetPCIInfo;
|
||||||
virDomainDriverParseBlkioDeviceStr;
|
virDomainDriverParseBlkioDeviceStr;
|
||||||
virDomainDriverSetupPersistentDefBlkioParams;
|
virDomainDriverSetupPersistentDefBlkioParams;
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
#include "cpu/cpu.h"
|
#include "cpu/cpu.h"
|
||||||
#include "virutil.h"
|
#include "virutil.h"
|
||||||
#include "domain_validate.h"
|
#include "domain_validate.h"
|
||||||
|
#include "domain_driver.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_LIBXL
|
#define VIR_FROM_THIS VIR_FROM_LIBXL
|
||||||
|
|
||||||
@ -5773,37 +5774,6 @@ libxlConnectSupportsFeature(virConnectPtr conn, int feature)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
libxlNodeDeviceGetPCIInfo(virNodeDeviceDefPtr def,
|
|
||||||
unsigned *domain,
|
|
||||||
unsigned *bus,
|
|
||||||
unsigned *slot,
|
|
||||||
unsigned *function)
|
|
||||||
{
|
|
||||||
virNodeDevCapsDefPtr cap;
|
|
||||||
|
|
||||||
cap = def->caps;
|
|
||||||
while (cap) {
|
|
||||||
if (cap->data.type == VIR_NODE_DEV_CAP_PCI_DEV) {
|
|
||||||
*domain = cap->data.pci_dev.domain;
|
|
||||||
*bus = cap->data.pci_dev.bus;
|
|
||||||
*slot = cap->data.pci_dev.slot;
|
|
||||||
*function = cap->data.pci_dev.function;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
cap = cap->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cap) {
|
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
|
||||||
_("device %s is not a PCI device"), def->name);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
libxlNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
libxlNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
||||||
const char *driverName,
|
const char *driverName,
|
||||||
@ -5845,7 +5815,7 @@ libxlNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
|||||||
if (virNodeDeviceDetachFlagsEnsureACL(dev->conn, def) < 0)
|
if (virNodeDeviceDetachFlagsEnsureACL(dev->conn, def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (libxlNodeDeviceGetPCIInfo(def, &domain, &bus, &slot, &function) < 0)
|
if (virDomainDriverNodeDeviceGetPCIInfo(def, &domain, &bus, &slot, &function) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
pci = virPCIDeviceNew(domain, bus, slot, function);
|
pci = virPCIDeviceNew(domain, bus, slot, function);
|
||||||
@ -5916,7 +5886,7 @@ libxlNodeDeviceReAttach(virNodeDevicePtr dev)
|
|||||||
if (virNodeDeviceReAttachEnsureACL(dev->conn, def) < 0)
|
if (virNodeDeviceReAttachEnsureACL(dev->conn, def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (libxlNodeDeviceGetPCIInfo(def, &domain, &bus, &slot, &function) < 0)
|
if (virDomainDriverNodeDeviceGetPCIInfo(def, &domain, &bus, &slot, &function) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
pci = virPCIDeviceNew(domain, bus, slot, function);
|
pci = virPCIDeviceNew(domain, bus, slot, function);
|
||||||
@ -5974,7 +5944,7 @@ libxlNodeDeviceReset(virNodeDevicePtr dev)
|
|||||||
if (virNodeDeviceResetEnsureACL(dev->conn, def) < 0)
|
if (virNodeDeviceResetEnsureACL(dev->conn, def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (libxlNodeDeviceGetPCIInfo(def, &domain, &bus, &slot, &function) < 0)
|
if (virDomainDriverNodeDeviceGetPCIInfo(def, &domain, &bus, &slot, &function) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
pci = virPCIDeviceNew(domain, bus, slot, function);
|
pci = virPCIDeviceNew(domain, bus, slot, function);
|
||||||
|
@ -11964,37 +11964,6 @@ qemuDomainMigrateConfirm3Params(virDomainPtr domain,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
qemuNodeDeviceGetPCIInfo(virNodeDeviceDefPtr def,
|
|
||||||
unsigned *domain,
|
|
||||||
unsigned *bus,
|
|
||||||
unsigned *slot,
|
|
||||||
unsigned *function)
|
|
||||||
{
|
|
||||||
virNodeDevCapsDefPtr cap;
|
|
||||||
|
|
||||||
cap = def->caps;
|
|
||||||
while (cap) {
|
|
||||||
if (cap->data.type == VIR_NODE_DEV_CAP_PCI_DEV) {
|
|
||||||
*domain = cap->data.pci_dev.domain;
|
|
||||||
*bus = cap->data.pci_dev.bus;
|
|
||||||
*slot = cap->data.pci_dev.slot;
|
|
||||||
*function = cap->data.pci_dev.function;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
cap = cap->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cap) {
|
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
|
||||||
_("device %s is not a PCI device"), def->name);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
||||||
const char *driverName,
|
const char *driverName,
|
||||||
@ -12037,7 +12006,7 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
|||||||
if (virNodeDeviceDetachFlagsEnsureACL(dev->conn, def) < 0)
|
if (virNodeDeviceDetachFlagsEnsureACL(dev->conn, def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuNodeDeviceGetPCIInfo(def, &domain, &bus, &slot, &function) < 0)
|
if (virDomainDriverNodeDeviceGetPCIInfo(def, &domain, &bus, &slot, &function) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
pci = virPCIDeviceNew(domain, bus, slot, function);
|
pci = virPCIDeviceNew(domain, bus, slot, function);
|
||||||
@ -12118,7 +12087,7 @@ qemuNodeDeviceReAttach(virNodeDevicePtr dev)
|
|||||||
if (virNodeDeviceReAttachEnsureACL(dev->conn, def) < 0)
|
if (virNodeDeviceReAttachEnsureACL(dev->conn, def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuNodeDeviceGetPCIInfo(def, &domain, &bus, &slot, &function) < 0)
|
if (virDomainDriverNodeDeviceGetPCIInfo(def, &domain, &bus, &slot, &function) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
pci = virPCIDeviceNew(domain, bus, slot, function);
|
pci = virPCIDeviceNew(domain, bus, slot, function);
|
||||||
@ -12172,7 +12141,7 @@ qemuNodeDeviceReset(virNodeDevicePtr dev)
|
|||||||
if (virNodeDeviceResetEnsureACL(dev->conn, def) < 0)
|
if (virNodeDeviceResetEnsureACL(dev->conn, def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuNodeDeviceGetPCIInfo(def, &domain, &bus, &slot, &function) < 0)
|
if (virDomainDriverNodeDeviceGetPCIInfo(def, &domain, &bus, &slot, &function) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
pci = virPCIDeviceNew(domain, bus, slot, function);
|
pci = virPCIDeviceNew(domain, bus, slot, function);
|
||||||
|
Loading…
Reference in New Issue
Block a user