mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-12 07:42:56 +00:00
libxl: Add libxlDomObjFromDomain
Similar to the QEMU and LXC drivers, add a helper function to lookup a domain, and use it instead of much copy and paste.
This commit is contained in:
parent
21bdbb829f
commit
0d87fd0aa9
@ -77,6 +77,27 @@ static int
|
|||||||
libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
|
libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
|
||||||
bool start_paused, int restore_fd);
|
bool start_paused, int restore_fd);
|
||||||
|
|
||||||
|
|
||||||
|
/* Function definitions */
|
||||||
|
static virDomainObjPtr
|
||||||
|
libxlDomObjFromDomain(virDomainPtr dom)
|
||||||
|
{
|
||||||
|
virDomainObjPtr vm;
|
||||||
|
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
||||||
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
|
|
||||||
|
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||||
|
if (!vm) {
|
||||||
|
virUUIDFormat(dom->uuid, uuidstr);
|
||||||
|
virReportError(VIR_ERR_NO_DOMAIN,
|
||||||
|
_("no domain with matching uuid '%s' (%s)"),
|
||||||
|
uuidstr, dom->name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return vm;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
libxlDomainEventQueue(libxlDriverPrivatePtr driver, virDomainEventPtr event)
|
libxlDomainEventQueue(libxlDriverPrivatePtr driver, virDomainEventPtr event)
|
||||||
{
|
{
|
||||||
@ -1267,14 +1288,8 @@ libxlDomainSuspend(virDomainPtr dom)
|
|||||||
virDomainEventPtr event = NULL;
|
virDomainEventPtr event = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
|
||||||
_("No domain with matching uuid '%s'"), uuidstr);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainSuspendEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainSuspendEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1325,14 +1340,8 @@ libxlDomainResume(virDomainPtr dom)
|
|||||||
virDomainEventPtr event = NULL;
|
virDomainEventPtr event = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
|
||||||
_("No domain with matching uuid '%s'"), uuidstr);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainResumeEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainResumeEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1376,21 +1385,14 @@ cleanup:
|
|||||||
static int
|
static int
|
||||||
libxlDomainShutdownFlags(virDomainPtr dom, unsigned int flags)
|
libxlDomainShutdownFlags(virDomainPtr dom, unsigned int flags)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
libxlDomainObjPrivatePtr priv;
|
libxlDomainObjPrivatePtr priv;
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
|
||||||
_("No domain with matching uuid '%s'"), uuidstr);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1430,21 +1432,14 @@ libxlDomainShutdown(virDomainPtr dom)
|
|||||||
static int
|
static int
|
||||||
libxlDomainReboot(virDomainPtr dom, unsigned int flags)
|
libxlDomainReboot(virDomainPtr dom, unsigned int flags)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
libxlDomainObjPrivatePtr priv;
|
libxlDomainObjPrivatePtr priv;
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
|
||||||
_("No domain with matching uuid '%s'"), uuidstr);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainRebootEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainRebootEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1481,14 +1476,8 @@ libxlDomainDestroyFlags(virDomainPtr dom,
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
|
||||||
_("No domain with matching uuid '%s'"), uuidstr);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1532,18 +1521,11 @@ libxlDomainDestroy(virDomainPtr dom)
|
|||||||
static char *
|
static char *
|
||||||
libxlDomainGetOSType(virDomainPtr dom)
|
libxlDomainGetOSType(virDomainPtr dom)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
char *type = NULL;
|
char *type = NULL;
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
|
||||||
_("No domain with matching uuid '%s'"), uuidstr);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1560,15 +1542,11 @@ cleanup:
|
|||||||
static unsigned long long
|
static unsigned long long
|
||||||
libxlDomainGetMaxMemory(virDomainPtr dom)
|
libxlDomainGetMaxMemory(virDomainPtr dom)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
unsigned long long ret = 0;
|
unsigned long long ret = 0;
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainGetMaxMemoryEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetMaxMemoryEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1597,11 +1575,8 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
|
|||||||
VIR_DOMAIN_MEM_CONFIG |
|
VIR_DOMAIN_MEM_CONFIG |
|
||||||
VIR_DOMAIN_MEM_MAXIMUM, -1);
|
VIR_DOMAIN_MEM_MAXIMUM, -1);
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainSetMemoryFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainSetMemoryFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1714,18 +1689,13 @@ libxlDomainSetMaxMemory(virDomainPtr dom, unsigned long memory)
|
|||||||
static int
|
static int
|
||||||
libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
|
libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
libxl_dominfo d_info;
|
libxl_dominfo d_info;
|
||||||
libxlDomainObjPrivatePtr priv;
|
libxlDomainObjPrivatePtr priv;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
|
||||||
_("no domain with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainGetInfoEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetInfoEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1762,18 +1732,13 @@ libxlDomainGetState(virDomainPtr dom,
|
|||||||
int *reason,
|
int *reason,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
|
||||||
_("no domain with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainGetStateEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetStateEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1879,14 +1844,8 @@ libxlDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
|
||||||
_("No domain with matching uuid '%s'"), uuidstr);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainSaveFlagsEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainSaveFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1997,14 +1956,8 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
|
|||||||
|
|
||||||
virCheckFlags(VIR_DUMP_LIVE | VIR_DUMP_CRASH, -1);
|
virCheckFlags(VIR_DUMP_LIVE | VIR_DUMP_CRASH, -1);
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
|
||||||
_("No domain with matching uuid '%s'"), uuidstr);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainCoreDumpEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainCoreDumpEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2083,14 +2036,8 @@ libxlDomainManagedSave(virDomainPtr dom, unsigned int flags)
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
|
||||||
_("No domain with matching uuid '%s'"), uuidstr);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainManagedSaveEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainManagedSaveEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2153,20 +2100,13 @@ cleanup:
|
|||||||
static int
|
static int
|
||||||
libxlDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
|
libxlDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
|
||||||
_("No domain with matching uuid '%s'"), uuidstr);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainHasManagedSaveImageEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainHasManagedSaveImageEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2189,14 +2129,8 @@ libxlDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags)
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
|
||||||
_("No domain with matching uuid '%s'"), uuidstr);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainManagedSaveRemoveEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainManagedSaveRemoveEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2251,11 +2185,8 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainSetVcpusFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainSetVcpusFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2359,7 +2290,6 @@ libxlDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
|
|||||||
static int
|
static int
|
||||||
libxlDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
|
libxlDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
virDomainDefPtr def;
|
virDomainDefPtr def;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -2369,11 +2299,8 @@ libxlDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
|
|||||||
VIR_DOMAIN_VCPU_CONFIG |
|
VIR_DOMAIN_VCPU_CONFIG |
|
||||||
VIR_DOMAIN_VCPU_MAXIMUM, -1);
|
VIR_DOMAIN_VCPU_MAXIMUM, -1);
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainGetVcpusFlagsEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetVcpusFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2427,11 +2354,8 @@ libxlDomainPinVcpu(virDomainPtr dom, unsigned int vcpu, unsigned char *cpumap,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
libxl_bitmap map;
|
libxl_bitmap map;
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainPinVcpuEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainPinVcpuEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2484,7 +2408,6 @@ static int
|
|||||||
libxlDomainGetVcpus(virDomainPtr dom, virVcpuInfoPtr info, int maxinfo,
|
libxlDomainGetVcpus(virDomainPtr dom, virVcpuInfoPtr info, int maxinfo,
|
||||||
unsigned char *cpumaps, int maplen)
|
unsigned char *cpumaps, int maplen)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
libxlDomainObjPrivatePtr priv;
|
libxlDomainObjPrivatePtr priv;
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -2493,11 +2416,8 @@ libxlDomainGetVcpus(virDomainPtr dom, virVcpuInfoPtr info, int maxinfo,
|
|||||||
size_t i;
|
size_t i;
|
||||||
unsigned char *cpumap;
|
unsigned char *cpumap;
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainGetVcpusEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetVcpusEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2550,18 +2470,13 @@ cleanup:
|
|||||||
static char *
|
static char *
|
||||||
libxlDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
|
libxlDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
|
|
||||||
/* Flags checked by virDomainDefFormat */
|
/* Flags checked by virDomainDefFormat */
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
|
||||||
_("no domain with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainGetXMLDescEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainGetXMLDescEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2704,14 +2619,8 @@ libxlDomainCreateWithFlags(virDomainPtr dom,
|
|||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_START_PAUSED, -1);
|
virCheckFlags(VIR_DOMAIN_START_PAUSED, -1);
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
|
||||||
_("No domain with matching uuid '%s'"), uuidstr);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2811,15 +2720,8 @@ libxlDomainUndefineFlags(virDomainPtr dom,
|
|||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_UNDEFINE_MANAGED_SAVE, -1);
|
virCheckFlags(VIR_DOMAIN_UNDEFINE_MANAGED_SAVE, -1);
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
|
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
|
||||||
_("no domain with matching uuid '%s'"), uuidstr);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainUndefineFlagsEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainUndefineFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3240,11 +3142,8 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
|
|||||||
virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE |
|
virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE |
|
||||||
VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1);
|
VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1);
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainAttachDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainAttachDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3347,11 +3246,8 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
|
|||||||
virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE |
|
virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE |
|
||||||
VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1);
|
VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1);
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainDetachDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainDetachDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3454,11 +3350,8 @@ libxlDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
|
|||||||
virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE |
|
virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE |
|
||||||
VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1);
|
VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1);
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainUpdateDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainUpdateDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3650,18 +3543,11 @@ libxlConnectDomainEventDeregister(virConnectPtr conn,
|
|||||||
static int
|
static int
|
||||||
libxlDomainGetAutostart(virDomainPtr dom, int *autostart)
|
libxlDomainGetAutostart(virDomainPtr dom, int *autostart)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
|
||||||
_("No domain with matching uuid '%s'"), uuidstr);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainGetAutostartEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetAutostartEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3684,14 +3570,8 @@ libxlDomainSetAutostart(virDomainPtr dom, int autostart)
|
|||||||
char *configFile = NULL, *autostartLink = NULL;
|
char *configFile = NULL, *autostartLink = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
|
||||||
_("No domain with matching uuid '%s'"), uuidstr);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainSetAutostartEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainSetAutostartEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3749,18 +3629,14 @@ cleanup:
|
|||||||
static char *
|
static char *
|
||||||
libxlDomainGetSchedulerType(virDomainPtr dom, int *nparams)
|
libxlDomainGetSchedulerType(virDomainPtr dom, int *nparams)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
libxlDomainObjPrivatePtr priv;
|
libxlDomainObjPrivatePtr priv;
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
char * ret = NULL;
|
char * ret = NULL;
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
libxl_scheduler sched_id;
|
libxl_scheduler sched_id;
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainGetSchedulerTypeEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetSchedulerTypeEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3811,7 +3687,6 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
int *nparams,
|
int *nparams,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
libxlDomainObjPrivatePtr priv;
|
libxlDomainObjPrivatePtr priv;
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
libxl_domain_sched_params sc_info;
|
libxl_domain_sched_params sc_info;
|
||||||
@ -3823,12 +3698,8 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
/* We don't return strings, and thus trivially support this flag. */
|
/* We don't return strings, and thus trivially support this flag. */
|
||||||
flags &= ~VIR_TYPED_PARAM_STRING_OKAY;
|
flags &= ~VIR_TYPED_PARAM_STRING_OKAY;
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
|
||||||
_("no domain with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainGetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3889,7 +3760,6 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
int nparams,
|
int nparams,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
libxlDomainObjPrivatePtr priv;
|
libxlDomainObjPrivatePtr priv;
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
libxl_domain_sched_params sc_info;
|
libxl_domain_sched_params sc_info;
|
||||||
@ -3906,11 +3776,8 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainSetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainSetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3968,7 +3835,6 @@ libxlDomainOpenConsole(virDomainPtr dom,
|
|||||||
virStreamPtr st,
|
virStreamPtr st,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virDomainChrDefPtr chr = NULL;
|
virDomainChrDefPtr chr = NULL;
|
||||||
@ -3984,14 +3850,8 @@ libxlDomainOpenConsole(virDomainPtr dom,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
|
||||||
_("No domain with matching uuid '%s'"), uuidstr);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -4067,7 +3927,6 @@ libxlDomainGetNumaParameters(virDomainPtr dom,
|
|||||||
int *nparams,
|
int *nparams,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
libxlDomainObjPrivatePtr priv;
|
libxlDomainObjPrivatePtr priv;
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
libxl_bitmap nodemap;
|
libxl_bitmap nodemap;
|
||||||
@ -4085,12 +3944,8 @@ libxlDomainGetNumaParameters(virDomainPtr dom,
|
|||||||
* the filtering on behalf of older clients that can't parse it. */
|
* the filtering on behalf of older clients that can't parse it. */
|
||||||
flags &= ~VIR_TYPED_PARAM_STRING_OKAY;
|
flags &= ~VIR_TYPED_PARAM_STRING_OKAY;
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
|
||||||
_("no domain with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainGetNumaParametersEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetNumaParametersEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -4191,15 +4046,11 @@ cleanup:
|
|||||||
static int
|
static int
|
||||||
libxlDomainIsActive(virDomainPtr dom)
|
libxlDomainIsActive(virDomainPtr dom)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
virDomainObjPtr obj;
|
virDomainObjPtr obj;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
obj = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(obj = libxlDomObjFromDomain(dom)))
|
||||||
if (!obj) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainIsActiveEnsureACL(dom->conn, obj->def) < 0)
|
if (virDomainIsActiveEnsureACL(dom->conn, obj->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -4215,15 +4066,11 @@ libxlDomainIsActive(virDomainPtr dom)
|
|||||||
static int
|
static int
|
||||||
libxlDomainIsPersistent(virDomainPtr dom)
|
libxlDomainIsPersistent(virDomainPtr dom)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
virDomainObjPtr obj;
|
virDomainObjPtr obj;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
obj = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(obj = libxlDomObjFromDomain(dom)))
|
||||||
if (!obj) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainIsPersistentEnsureACL(dom->conn, obj->def) < 0)
|
if (virDomainIsPersistentEnsureACL(dom->conn, obj->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -4239,15 +4086,11 @@ libxlDomainIsPersistent(virDomainPtr dom)
|
|||||||
static int
|
static int
|
||||||
libxlDomainIsUpdated(virDomainPtr dom)
|
libxlDomainIsUpdated(virDomainPtr dom)
|
||||||
{
|
{
|
||||||
libxlDriverPrivatePtr driver = dom->conn->privateData;
|
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
if (!(vm = libxlDomObjFromDomain(dom)))
|
||||||
if (!vm) {
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainIsUpdatedEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainIsUpdatedEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user