mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
vcpu: make old API trivially wrap to new API
Note - this wrapping is completely mechanical; the old API will function identically, since the new API validates that the exact same flags are provided by the old API. On a per-driver basis, it may make sense to have the old API pass a different set of flags, but that should be done in the per-driver patch that implements the full range of flag support in the new API. * src/esx/esx_driver.c (esxDomainSetVcpus, escDomainGetMaxVpcus): Move guts... (esxDomainSetVcpusFlags, esxDomainGetVcpusFlags): ...to new functions. (esxDriver): Trivially support the new API. * src/openvz/openvz_driver.c (openvzDomainSetVcpus) (openvzDomainSetVcpusFlags, openvzDomainGetMaxVcpus) (openvzDomainGetVcpusFlags, openvzDriver): Likewise. * src/phyp/phyp_driver.c (phypDomainSetCPU) (phypDomainSetVcpusFlags, phypGetLparCPUMAX) (phypDomainGetVcpusFlags, phypDriver): Likewise. * src/qemu/qemu_driver.c (qemudDomainSetVcpus) (qemudDomainSetVcpusFlags, qemudDomainGetMaxVcpus) (qemudDomainGetVcpusFlags, qemuDriver): Likewise. * src/test/test_driver.c (testSetVcpus, testDomainSetVcpusFlags) (testDomainGetMaxVcpus, testDomainGetVcpusFlags, testDriver): Likewise. * src/vbox/vbox_tmpl.c (vboxDomainSetVcpus) (vboxDomainSetVcpusFlags, virDomainGetMaxVcpus) (virDomainGetVcpusFlags, virDriver): Likewise. * src/xen/xen_driver.c (xenUnifiedDomainSetVcpus) (xenUnifiedDomainSetVcpusFlags, xenUnifiedDomainGetMaxVcpus) (xenUnifiedDomainGetVcpusFlags, xenUnifiedDriver): Likewise. * src/xenapi/xenapi_driver.c (xenapiDomainSetVcpus) (xenapiDomainSetVcpusFlags, xenapiDomainGetMaxVcpus) (xenapiDomainGetVcpusFlags, xenapiDriver): Likewise. (xenapiError): New helper macro.
This commit is contained in:
parent
eb826444f9
commit
50c51f13e2
@ -2384,7 +2384,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
|
esxDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
int result = -1;
|
int result = -1;
|
||||||
esxPrivate *priv = domain->conn->privateData;
|
esxPrivate *priv = domain->conn->privateData;
|
||||||
@ -2394,6 +2395,11 @@ esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
|
|||||||
esxVI_ManagedObjectReference *task = NULL;
|
esxVI_ManagedObjectReference *task = NULL;
|
||||||
esxVI_TaskInfoState taskInfoState;
|
esxVI_TaskInfoState taskInfoState;
|
||||||
|
|
||||||
|
if (flags != VIR_DOMAIN_VCPU_LIVE) {
|
||||||
|
ESX_ERROR(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (nvcpus < 1) {
|
if (nvcpus < 1) {
|
||||||
ESX_ERROR(VIR_ERR_INVALID_ARG, "%s",
|
ESX_ERROR(VIR_ERR_INVALID_ARG, "%s",
|
||||||
_("Requested number of virtual CPUs must at least be 1"));
|
_("Requested number of virtual CPUs must at least be 1"));
|
||||||
@ -2453,15 +2459,26 @@ esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
|
||||||
|
{
|
||||||
|
return esxDomainSetVcpusFlags(domain, nvcpus, VIR_DOMAIN_VCPU_LIVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
esxDomainGetMaxVcpus(virDomainPtr domain)
|
esxDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
|
||||||
{
|
{
|
||||||
esxPrivate *priv = domain->conn->privateData;
|
esxPrivate *priv = domain->conn->privateData;
|
||||||
esxVI_String *propertyNameList = NULL;
|
esxVI_String *propertyNameList = NULL;
|
||||||
esxVI_ObjectContent *hostSystem = NULL;
|
esxVI_ObjectContent *hostSystem = NULL;
|
||||||
esxVI_DynamicProperty *dynamicProperty = NULL;
|
esxVI_DynamicProperty *dynamicProperty = NULL;
|
||||||
|
|
||||||
|
if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
|
||||||
|
ESX_ERROR(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (priv->maxVcpus > 0) {
|
if (priv->maxVcpus > 0) {
|
||||||
return priv->maxVcpus;
|
return priv->maxVcpus;
|
||||||
}
|
}
|
||||||
@ -2507,7 +2524,12 @@ esxDomainGetMaxVcpus(virDomainPtr domain)
|
|||||||
return priv->maxVcpus;
|
return priv->maxVcpus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
esxDomainGetMaxVcpus(virDomainPtr domain)
|
||||||
|
{
|
||||||
|
return esxDomainGetVcpusFlags(domain, (VIR_DOMAIN_VCPU_LIVE |
|
||||||
|
VIR_DOMAIN_VCPU_MAXIMUM));
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
esxDomainDumpXML(virDomainPtr domain, int flags)
|
esxDomainDumpXML(virDomainPtr domain, int flags)
|
||||||
@ -4160,8 +4182,8 @@ static virDriver esxDriver = {
|
|||||||
NULL, /* domainRestore */
|
NULL, /* domainRestore */
|
||||||
NULL, /* domainCoreDump */
|
NULL, /* domainCoreDump */
|
||||||
esxDomainSetVcpus, /* domainSetVcpus */
|
esxDomainSetVcpus, /* domainSetVcpus */
|
||||||
NULL, /* domainSetVcpusFlags */
|
esxDomainSetVcpusFlags, /* domainSetVcpusFlags */
|
||||||
NULL, /* domainGetVcpusFlags */
|
esxDomainGetVcpusFlags, /* domainGetVcpusFlags */
|
||||||
NULL, /* domainPinVcpu */
|
NULL, /* domainPinVcpu */
|
||||||
NULL, /* domainGetVcpus */
|
NULL, /* domainGetVcpus */
|
||||||
esxDomainGetMaxVcpus, /* domainGetMaxVcpus */
|
esxDomainGetMaxVcpus, /* domainGetMaxVcpus */
|
||||||
|
@ -67,7 +67,6 @@
|
|||||||
static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid);
|
static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid);
|
||||||
static int openvzGetMaxVCPUs(virConnectPtr conn, const char *type);
|
static int openvzGetMaxVCPUs(virConnectPtr conn, const char *type);
|
||||||
static int openvzDomainGetMaxVcpus(virDomainPtr dom);
|
static int openvzDomainGetMaxVcpus(virDomainPtr dom);
|
||||||
static int openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus);
|
|
||||||
static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
|
static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
|
||||||
unsigned int nvcpus);
|
unsigned int nvcpus);
|
||||||
static int openvzDomainSetMemoryInternal(virDomainObjPtr vm,
|
static int openvzDomainSetMemoryInternal(virDomainObjPtr vm,
|
||||||
@ -1211,11 +1210,24 @@ static int openvzGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
openvzDomainGetVcpusFlags(virDomainPtr dom ATTRIBUTE_UNUSED,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
|
||||||
|
openvzError(VIR_ERR_INVALID_ARG, _("unsupported flags (0x%x)"), flags);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static int openvzDomainGetMaxVcpus(virDomainPtr dom ATTRIBUTE_UNUSED) {
|
|
||||||
return openvzGetMaxVCPUs(NULL, "openvz");
|
return openvzGetMaxVCPUs(NULL, "openvz");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int openvzDomainGetMaxVcpus(virDomainPtr dom)
|
||||||
|
{
|
||||||
|
return openvzDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_LIVE |
|
||||||
|
VIR_DOMAIN_VCPU_MAXIMUM));
|
||||||
|
}
|
||||||
|
|
||||||
static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
|
static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
|
||||||
unsigned int nvcpus)
|
unsigned int nvcpus)
|
||||||
{
|
{
|
||||||
@ -1241,12 +1253,18 @@ static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
|
static int openvzDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
struct openvz_driver *driver = dom->conn->privateData;
|
struct openvz_driver *driver = dom->conn->privateData;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
|
if (flags != VIR_DOMAIN_VCPU_LIVE) {
|
||||||
|
openvzError(VIR_ERR_INVALID_ARG, _("unsupported flags (0x%x)"), flags);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
openvzDriverLock(driver);
|
openvzDriverLock(driver);
|
||||||
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
@ -1272,6 +1290,12 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
|
||||||
|
{
|
||||||
|
return openvzDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_VCPU_LIVE);
|
||||||
|
}
|
||||||
|
|
||||||
static virDrvOpenStatus openvzOpen(virConnectPtr conn,
|
static virDrvOpenStatus openvzOpen(virConnectPtr conn,
|
||||||
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
||||||
int flags ATTRIBUTE_UNUSED)
|
int flags ATTRIBUTE_UNUSED)
|
||||||
@ -1590,8 +1614,8 @@ static virDriver openvzDriver = {
|
|||||||
NULL, /* domainRestore */
|
NULL, /* domainRestore */
|
||||||
NULL, /* domainCoreDump */
|
NULL, /* domainCoreDump */
|
||||||
openvzDomainSetVcpus, /* domainSetVcpus */
|
openvzDomainSetVcpus, /* domainSetVcpus */
|
||||||
NULL, /* domainSetVcpusFlags */
|
openvzDomainSetVcpusFlags, /* domainSetVcpusFlags */
|
||||||
NULL, /* domainGetVcpusFlags */
|
openvzDomainGetVcpusFlags, /* domainGetVcpusFlags */
|
||||||
NULL, /* domainPinVcpu */
|
NULL, /* domainPinVcpu */
|
||||||
NULL, /* domainGetVcpus */
|
NULL, /* domainGetVcpus */
|
||||||
openvzDomainGetMaxVcpus, /* domainGetMaxVcpus */
|
openvzDomainGetMaxVcpus, /* domainGetMaxVcpus */
|
||||||
|
@ -1497,14 +1497,26 @@ phypGetLparCPU(virConnectPtr conn, const char *managed_system, int lpar_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
phypGetLparCPUMAX(virDomainPtr dom)
|
phypDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
|
||||||
{
|
{
|
||||||
phyp_driverPtr phyp_driver = dom->conn->privateData;
|
phyp_driverPtr phyp_driver = dom->conn->privateData;
|
||||||
char *managed_system = phyp_driver->managed_system;
|
char *managed_system = phyp_driver->managed_system;
|
||||||
|
|
||||||
|
if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
|
||||||
|
PHYP_ERROR(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return phypGetLparCPUGeneric(dom->conn, managed_system, dom->id, 1);
|
return phypGetLparCPUGeneric(dom->conn, managed_system, dom->id, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
phypGetLparCPUMAX(virDomainPtr dom)
|
||||||
|
{
|
||||||
|
return phypDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_LIVE |
|
||||||
|
VIR_DOMAIN_VCPU_MAXIMUM));
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
phypGetRemoteSlot(virConnectPtr conn, const char *managed_system,
|
phypGetRemoteSlot(virConnectPtr conn, const char *managed_system,
|
||||||
const char *lpar_name)
|
const char *lpar_name)
|
||||||
@ -3831,7 +3843,8 @@ phypConnectGetCapabilities(virConnectPtr conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus)
|
phypDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
ConnectionData *connection_data = dom->conn->networkPrivateData;
|
ConnectionData *connection_data = dom->conn->networkPrivateData;
|
||||||
phyp_driverPtr phyp_driver = dom->conn->privateData;
|
phyp_driverPtr phyp_driver = dom->conn->privateData;
|
||||||
@ -3846,6 +3859,11 @@ phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus)
|
|||||||
unsigned int amount = 0;
|
unsigned int amount = 0;
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
|
if (flags != VIR_DOMAIN_VCPU_LIVE) {
|
||||||
|
PHYP_ERROR(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if ((ncpus = phypGetLparCPU(dom->conn, managed_system, dom->id)) == 0)
|
if ((ncpus = phypGetLparCPU(dom->conn, managed_system, dom->id)) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -3891,6 +3909,12 @@ phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus)
|
||||||
|
{
|
||||||
|
return phypDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_VCPU_LIVE);
|
||||||
|
}
|
||||||
|
|
||||||
static virDrvOpenStatus
|
static virDrvOpenStatus
|
||||||
phypVIOSDriverOpen(virConnectPtr conn,
|
phypVIOSDriverOpen(virConnectPtr conn,
|
||||||
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
||||||
@ -3941,8 +3965,8 @@ static virDriver phypDriver = {
|
|||||||
NULL, /* domainRestore */
|
NULL, /* domainRestore */
|
||||||
NULL, /* domainCoreDump */
|
NULL, /* domainCoreDump */
|
||||||
phypDomainSetCPU, /* domainSetVcpus */
|
phypDomainSetCPU, /* domainSetVcpus */
|
||||||
NULL, /* domainSetVcpusFlags */
|
phypDomainSetVcpusFlags, /* domainSetVcpusFlags */
|
||||||
NULL, /* domainGetVcpusFlags */
|
phypDomainGetVcpusFlags, /* domainGetVcpusFlags */
|
||||||
NULL, /* domainPinVcpu */
|
NULL, /* domainPinVcpu */
|
||||||
NULL, /* domainGetVcpus */
|
NULL, /* domainGetVcpus */
|
||||||
phypGetLparCPUMAX, /* domainGetMaxVcpus */
|
phypGetLparCPUMAX, /* domainGetMaxVcpus */
|
||||||
|
@ -5934,13 +5934,22 @@ unsupported:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
|
static int
|
||||||
|
qemudDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
struct qemud_driver *driver = dom->conn->privateData;
|
struct qemud_driver *driver = dom->conn->privateData;
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
const char * type;
|
const char * type;
|
||||||
int max;
|
int max;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
|
if (flags != VIR_DOMAIN_VCPU_LIVE) {
|
||||||
|
qemuReportError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"),
|
||||||
|
flags);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
qemuDriverLock(driver);
|
qemuDriverLock(driver);
|
||||||
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
qemuDriverUnlock(driver);
|
qemuDriverUnlock(driver);
|
||||||
@ -5994,6 +6003,12 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
|
||||||
|
{
|
||||||
|
return qemudDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_VCPU_LIVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemudDomainPinVcpu(virDomainPtr dom,
|
qemudDomainPinVcpu(virDomainPtr dom,
|
||||||
@ -6150,12 +6165,20 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int qemudDomainGetMaxVcpus(virDomainPtr dom) {
|
static int
|
||||||
|
qemudDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
|
||||||
|
{
|
||||||
struct qemud_driver *driver = dom->conn->privateData;
|
struct qemud_driver *driver = dom->conn->privateData;
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
const char *type;
|
const char *type;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
|
if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
|
||||||
|
qemuReportError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"),
|
||||||
|
flags);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
qemuDriverLock(driver);
|
qemuDriverLock(driver);
|
||||||
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
qemuDriverUnlock(driver);
|
qemuDriverUnlock(driver);
|
||||||
@ -6183,6 +6206,13 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemudDomainGetMaxVcpus(virDomainPtr dom)
|
||||||
|
{
|
||||||
|
return qemudDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_LIVE |
|
||||||
|
VIR_DOMAIN_VCPU_MAXIMUM));
|
||||||
|
}
|
||||||
|
|
||||||
static int qemudDomainGetSecurityLabel(virDomainPtr dom, virSecurityLabelPtr seclabel)
|
static int qemudDomainGetSecurityLabel(virDomainPtr dom, virSecurityLabelPtr seclabel)
|
||||||
{
|
{
|
||||||
struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
|
struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
|
||||||
@ -12938,8 +12968,8 @@ static virDriver qemuDriver = {
|
|||||||
qemudDomainRestore, /* domainRestore */
|
qemudDomainRestore, /* domainRestore */
|
||||||
qemudDomainCoreDump, /* domainCoreDump */
|
qemudDomainCoreDump, /* domainCoreDump */
|
||||||
qemudDomainSetVcpus, /* domainSetVcpus */
|
qemudDomainSetVcpus, /* domainSetVcpus */
|
||||||
NULL, /* domainSetVcpusFlags */
|
qemudDomainSetVcpusFlags, /* domainSetVcpusFlags */
|
||||||
NULL, /* domainGetVcpusFlags */
|
qemudDomainGetVcpusFlags, /* domainGetVcpusFlags */
|
||||||
qemudDomainPinVcpu, /* domainPinVcpu */
|
qemudDomainPinVcpu, /* domainPinVcpu */
|
||||||
qemudDomainGetVcpus, /* domainGetVcpus */
|
qemudDomainGetVcpus, /* domainGetVcpus */
|
||||||
qemudDomainGetMaxVcpus, /* domainGetMaxVcpus */
|
qemudDomainGetMaxVcpus, /* domainGetMaxVcpus */
|
||||||
|
@ -2029,17 +2029,37 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int testDomainGetMaxVcpus(virDomainPtr domain)
|
static int
|
||||||
|
testDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
|
||||||
{
|
{
|
||||||
|
if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
|
||||||
|
testError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return testGetMaxVCPUs(domain->conn, "test");
|
return testGetMaxVCPUs(domain->conn, "test");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int testSetVcpus(virDomainPtr domain,
|
static int
|
||||||
unsigned int nrCpus) {
|
testDomainGetMaxVcpus(virDomainPtr domain)
|
||||||
|
{
|
||||||
|
return testDomainGetVcpusFlags(domain, (VIR_DOMAIN_VCPU_LIVE |
|
||||||
|
VIR_DOMAIN_VCPU_MAXIMUM));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
testConnPtr privconn = domain->conn->privateData;
|
testConnPtr privconn = domain->conn->privateData;
|
||||||
virDomainObjPtr privdom = NULL;
|
virDomainObjPtr privdom = NULL;
|
||||||
int ret = -1, maxvcpus;
|
int ret = -1, maxvcpus;
|
||||||
|
|
||||||
|
if (flags != VIR_DOMAIN_VCPU_LIVE) {
|
||||||
|
testError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Do this first before locking */
|
/* Do this first before locking */
|
||||||
maxvcpus = testDomainGetMaxVcpus(domain);
|
maxvcpus = testDomainGetMaxVcpus(domain);
|
||||||
if (maxvcpus < 0)
|
if (maxvcpus < 0)
|
||||||
@ -2082,6 +2102,12 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
testSetVcpus(virDomainPtr domain, unsigned int nrCpus)
|
||||||
|
{
|
||||||
|
return testDomainSetVcpusFlags(domain, nrCpus, VIR_DOMAIN_VCPU_LIVE);
|
||||||
|
}
|
||||||
|
|
||||||
static int testDomainGetVcpus(virDomainPtr domain,
|
static int testDomainGetVcpus(virDomainPtr domain,
|
||||||
virVcpuInfoPtr info,
|
virVcpuInfoPtr info,
|
||||||
int maxinfo,
|
int maxinfo,
|
||||||
@ -5260,8 +5286,8 @@ static virDriver testDriver = {
|
|||||||
testDomainRestore, /* domainRestore */
|
testDomainRestore, /* domainRestore */
|
||||||
testDomainCoreDump, /* domainCoreDump */
|
testDomainCoreDump, /* domainCoreDump */
|
||||||
testSetVcpus, /* domainSetVcpus */
|
testSetVcpus, /* domainSetVcpus */
|
||||||
NULL, /* domainSetVcpusFlags */
|
testDomainSetVcpusFlags, /* domainSetVcpusFlags */
|
||||||
NULL, /* domainGetVcpusFlags */
|
testDomainGetVcpusFlags, /* domainGetVcpusFlags */
|
||||||
testDomainPinVcpu, /* domainPinVcpu */
|
testDomainPinVcpu, /* domainPinVcpu */
|
||||||
testDomainGetVcpus, /* domainGetVcpus */
|
testDomainGetVcpus, /* domainGetVcpus */
|
||||||
testDomainGetMaxVcpus, /* domainGetMaxVcpus */
|
testDomainGetMaxVcpus, /* domainGetMaxVcpus */
|
||||||
|
@ -1839,13 +1839,21 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vboxDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
|
static int
|
||||||
|
vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
VBOX_OBJECT_CHECK(dom->conn, int, -1);
|
VBOX_OBJECT_CHECK(dom->conn, int, -1);
|
||||||
IMachine *machine = NULL;
|
IMachine *machine = NULL;
|
||||||
vboxIID *iid = NULL;
|
vboxIID *iid = NULL;
|
||||||
PRUint32 CPUCount = nvcpus;
|
PRUint32 CPUCount = nvcpus;
|
||||||
nsresult rc;
|
nsresult rc;
|
||||||
|
|
||||||
|
if (flags != VIR_DOMAIN_VCPU_LIVE) {
|
||||||
|
vboxError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
#if VBOX_API_VERSION == 2002
|
#if VBOX_API_VERSION == 2002
|
||||||
if (VIR_ALLOC(iid) < 0) {
|
if (VIR_ALLOC(iid) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
@ -1887,11 +1895,24 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vboxDomainGetMaxVcpus(virDomainPtr dom) {
|
static int
|
||||||
|
vboxDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
|
||||||
|
{
|
||||||
|
return vboxDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_VCPU_LIVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
vboxDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
|
||||||
|
{
|
||||||
VBOX_OBJECT_CHECK(dom->conn, int, -1);
|
VBOX_OBJECT_CHECK(dom->conn, int, -1);
|
||||||
ISystemProperties *systemProperties = NULL;
|
ISystemProperties *systemProperties = NULL;
|
||||||
PRUint32 maxCPUCount = 0;
|
PRUint32 maxCPUCount = 0;
|
||||||
|
|
||||||
|
if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
|
||||||
|
vboxError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Currently every domain supports the same number of max cpus
|
/* Currently every domain supports the same number of max cpus
|
||||||
* as that supported by vbox and thus take it directly from
|
* as that supported by vbox and thus take it directly from
|
||||||
* the systemproperties.
|
* the systemproperties.
|
||||||
@ -1909,6 +1930,13 @@ static int vboxDomainGetMaxVcpus(virDomainPtr dom) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
vboxDomainGetMaxVcpus(virDomainPtr dom)
|
||||||
|
{
|
||||||
|
return vboxDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_LIVE |
|
||||||
|
VIR_DOMAIN_VCPU_MAXIMUM));
|
||||||
|
}
|
||||||
|
|
||||||
static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
|
static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
|
||||||
VBOX_OBJECT_CHECK(dom->conn, char *, NULL);
|
VBOX_OBJECT_CHECK(dom->conn, char *, NULL);
|
||||||
virDomainDefPtr def = NULL;
|
virDomainDefPtr def = NULL;
|
||||||
@ -8267,8 +8295,8 @@ virDriver NAME(Driver) = {
|
|||||||
NULL, /* domainRestore */
|
NULL, /* domainRestore */
|
||||||
NULL, /* domainCoreDump */
|
NULL, /* domainCoreDump */
|
||||||
vboxDomainSetVcpus, /* domainSetVcpus */
|
vboxDomainSetVcpus, /* domainSetVcpus */
|
||||||
NULL, /* domainSetVcpusFlags */
|
vboxDomainSetVcpusFlags, /* domainSetVcpusFlags */
|
||||||
NULL, /* domainGetVcpusFlags */
|
vboxDomainGetVcpusFlags, /* domainGetVcpusFlags */
|
||||||
NULL, /* domainPinVcpu */
|
NULL, /* domainPinVcpu */
|
||||||
NULL, /* domainGetVcpus */
|
NULL, /* domainGetVcpus */
|
||||||
vboxDomainGetMaxVcpus, /* domainGetMaxVcpus */
|
vboxDomainGetMaxVcpus, /* domainGetMaxVcpus */
|
||||||
|
@ -1069,11 +1069,18 @@ xenUnifiedDomainCoreDump (virDomainPtr dom, const char *to, int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xenUnifiedDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
|
xenUnifiedDomainSetVcpusFlags (virDomainPtr dom, unsigned int nvcpus,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
GET_PRIVATE(dom->conn);
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (flags != VIR_DOMAIN_VCPU_LIVE) {
|
||||||
|
xenUnifiedError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"),
|
||||||
|
flags);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Try non-hypervisor methods first, then hypervisor direct method
|
/* Try non-hypervisor methods first, then hypervisor direct method
|
||||||
* as a last resort.
|
* as a last resort.
|
||||||
*/
|
*/
|
||||||
@ -1092,6 +1099,12 @@ xenUnifiedDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
xenUnifiedDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
|
||||||
|
{
|
||||||
|
return xenUnifiedDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_VCPU_LIVE);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xenUnifiedDomainPinVcpu (virDomainPtr dom, unsigned int vcpu,
|
xenUnifiedDomainPinVcpu (virDomainPtr dom, unsigned int vcpu,
|
||||||
unsigned char *cpumap, int maplen)
|
unsigned char *cpumap, int maplen)
|
||||||
@ -1126,11 +1139,17 @@ xenUnifiedDomainGetVcpus (virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xenUnifiedDomainGetMaxVcpus (virDomainPtr dom)
|
xenUnifiedDomainGetVcpusFlags (virDomainPtr dom, unsigned int flags)
|
||||||
{
|
{
|
||||||
GET_PRIVATE(dom->conn);
|
GET_PRIVATE(dom->conn);
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
|
if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
|
||||||
|
xenUnifiedError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"),
|
||||||
|
flags);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (priv->opened[i] && drivers[i]->domainGetMaxVcpus) {
|
if (priv->opened[i] && drivers[i]->domainGetMaxVcpus) {
|
||||||
ret = drivers[i]->domainGetMaxVcpus (dom);
|
ret = drivers[i]->domainGetMaxVcpus (dom);
|
||||||
@ -1140,6 +1159,13 @@ xenUnifiedDomainGetMaxVcpus (virDomainPtr dom)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
xenUnifiedDomainGetMaxVcpus (virDomainPtr dom)
|
||||||
|
{
|
||||||
|
return xenUnifiedDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_LIVE |
|
||||||
|
VIR_DOMAIN_VCPU_MAXIMUM));
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
xenUnifiedDomainDumpXML (virDomainPtr dom, int flags)
|
xenUnifiedDomainDumpXML (virDomainPtr dom, int flags)
|
||||||
{
|
{
|
||||||
@ -1951,8 +1977,8 @@ static virDriver xenUnifiedDriver = {
|
|||||||
xenUnifiedDomainRestore, /* domainRestore */
|
xenUnifiedDomainRestore, /* domainRestore */
|
||||||
xenUnifiedDomainCoreDump, /* domainCoreDump */
|
xenUnifiedDomainCoreDump, /* domainCoreDump */
|
||||||
xenUnifiedDomainSetVcpus, /* domainSetVcpus */
|
xenUnifiedDomainSetVcpus, /* domainSetVcpus */
|
||||||
NULL, /* domainSetVcpusFlags */
|
xenUnifiedDomainSetVcpusFlags, /* domainSetVcpusFlags */
|
||||||
NULL, /* domainGetVcpusFlags */
|
xenUnifiedDomainGetVcpusFlags, /* domainGetVcpusFlags */
|
||||||
xenUnifiedDomainPinVcpu, /* domainPinVcpu */
|
xenUnifiedDomainPinVcpu, /* domainPinVcpu */
|
||||||
xenUnifiedDomainGetVcpus, /* domainGetVcpus */
|
xenUnifiedDomainGetVcpus, /* domainGetVcpus */
|
||||||
xenUnifiedDomainGetMaxVcpus, /* domainGetMaxVcpus */
|
xenUnifiedDomainGetMaxVcpus, /* domainGetMaxVcpus */
|
||||||
|
@ -40,6 +40,11 @@
|
|||||||
#include "xenapi_driver_private.h"
|
#include "xenapi_driver_private.h"
|
||||||
#include "xenapi_utils.h"
|
#include "xenapi_utils.h"
|
||||||
|
|
||||||
|
#define VIR_FROM_THIS VIR_FROM_XENAPI
|
||||||
|
|
||||||
|
#define xenapiError(code, ...) \
|
||||||
|
virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
|
||||||
|
__FUNCTION__, __LINE__, __VA_ARGS__)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* getCapsObject
|
* getCapsObject
|
||||||
@ -987,19 +992,26 @@ xenapiDomainGetInfo (virDomainPtr dom, virDomainInfoPtr info)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* xenapiDomainSetVcpus
|
* xenapiDomainSetVcpusFlags
|
||||||
*
|
*
|
||||||
* Sets the VCPUs on the domain
|
* Sets the VCPUs on the domain
|
||||||
* Return 0 on success or -1 in case of error
|
* Return 0 on success or -1 in case of error
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
xenapiDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
|
xenapiDomainSetVcpusFlags (virDomainPtr dom, unsigned int nvcpus,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* vm.set_vcpus_max */
|
/* vm.set_vcpus_max */
|
||||||
xen_vm vm;
|
xen_vm vm;
|
||||||
xen_vm_set *vms;
|
xen_vm_set *vms;
|
||||||
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
|
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
|
||||||
|
|
||||||
|
if (flags != VIR_DOMAIN_VCPU_LIVE) {
|
||||||
|
xenapiError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"),
|
||||||
|
flags);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
|
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
|
||||||
if (vms->size != 1) {
|
if (vms->size != 1) {
|
||||||
xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
|
xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
@ -1018,6 +1030,18 @@ xenapiDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* xenapiDomainSetVcpus
|
||||||
|
*
|
||||||
|
* Sets the VCPUs on the domain
|
||||||
|
* Return 0 on success or -1 in case of error
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
xenapiDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
|
||||||
|
{
|
||||||
|
return xenapiDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_VCPU_LIVE);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* xenapiDomainPinVcpu
|
* xenapiDomainPinVcpu
|
||||||
*
|
*
|
||||||
@ -1140,19 +1164,26 @@ xenapiDomainGetVcpus (virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* xenapiDomainGetMaxVcpus
|
* xenapiDomainGetVcpusFlags
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Returns maximum number of Vcpus on success or -1 in case of error
|
* Returns Vcpus count on success or -1 in case of error
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
xenapiDomainGetMaxVcpus (virDomainPtr dom)
|
xenapiDomainGetVcpusFlags (virDomainPtr dom, unsigned int flags)
|
||||||
{
|
{
|
||||||
xen_vm vm;
|
xen_vm vm;
|
||||||
xen_vm_set *vms;
|
xen_vm_set *vms;
|
||||||
int64_t maxvcpu = 0;
|
int64_t maxvcpu = 0;
|
||||||
enum xen_vm_power_state state;
|
enum xen_vm_power_state state;
|
||||||
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
|
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
|
||||||
|
|
||||||
|
if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
|
||||||
|
xenapiError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"),
|
||||||
|
flags);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
|
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
|
||||||
if (vms->size != 1) {
|
if (vms->size != 1) {
|
||||||
xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
|
xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
@ -1175,6 +1206,19 @@ xenapiDomainGetMaxVcpus (virDomainPtr dom)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* xenapiDomainGetMaxVcpus
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Returns maximum number of Vcpus on success or -1 in case of error
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
xenapiDomainGetMaxVcpus (virDomainPtr dom)
|
||||||
|
{
|
||||||
|
return xenapiDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_LIVE |
|
||||||
|
VIR_DOMAIN_VCPU_MAXIMUM));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* xenapiDomainDumpXML
|
* xenapiDomainDumpXML
|
||||||
*
|
*
|
||||||
@ -1754,8 +1798,8 @@ static virDriver xenapiDriver = {
|
|||||||
NULL, /* domainRestore */
|
NULL, /* domainRestore */
|
||||||
NULL, /* domainCoreDump */
|
NULL, /* domainCoreDump */
|
||||||
xenapiDomainSetVcpus, /* domainSetVcpus */
|
xenapiDomainSetVcpus, /* domainSetVcpus */
|
||||||
NULL, /* domainSetVcpusFlags */
|
xenapiDomainSetVcpusFlags, /* domainSetVcpusFlags */
|
||||||
NULL, /* domainGetVcpusFlags */
|
xenapiDomainGetVcpusFlags, /* domainGetVcpusFlags */
|
||||||
xenapiDomainPinVcpu, /* domainPinVcpu */
|
xenapiDomainPinVcpu, /* domainPinVcpu */
|
||||||
xenapiDomainGetVcpus, /* domainGetVcpus */
|
xenapiDomainGetVcpus, /* domainGetVcpus */
|
||||||
xenapiDomainGetMaxVcpus, /* domainGetMaxVcpus */
|
xenapiDomainGetMaxVcpus, /* domainGetMaxVcpus */
|
||||||
|
Loading…
Reference in New Issue
Block a user