mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
ch: Move and rename chDomObjFromDomain()
The chDomObjFromDomain() function which currently lives as a static one in ch_driver.c is going to be needed in other parts of the driver. Move it into ch_domain.c, rename to virCHDomainObjFromDomain() and expose in corresponding header file for the rest of the driver to use. Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com> Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
da6d4a2afc
commit
ae34b921d9
@ -27,6 +27,7 @@
|
|||||||
#include "virlog.h"
|
#include "virlog.h"
|
||||||
#include "virtime.h"
|
#include "virtime.h"
|
||||||
#include "virsystemd.h"
|
#include "virsystemd.h"
|
||||||
|
#include "datatypes.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_CH
|
#define VIR_FROM_THIS VIR_FROM_CH
|
||||||
|
|
||||||
@ -417,3 +418,32 @@ virCHDomainGetMachineName(virDomainObj *vm)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virCHDomainObjFromDomain:
|
||||||
|
* @domain: Domain pointer that has to be looked up
|
||||||
|
*
|
||||||
|
* This function looks up @domain and returns the appropriate virDomainObjPtr
|
||||||
|
* that has to be released by calling virDomainObjEndAPI().
|
||||||
|
*
|
||||||
|
* Returns the domain object with incremented reference counter which is locked
|
||||||
|
* on success, NULL otherwise.
|
||||||
|
*/
|
||||||
|
virDomainObj *
|
||||||
|
virCHDomainObjFromDomain(virDomainPtr domain)
|
||||||
|
{
|
||||||
|
virDomainObj *vm;
|
||||||
|
virCHDriver *driver = domain->conn->privateData;
|
||||||
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
|
|
||||||
|
vm = virDomainObjListFindByUUID(driver->domains, domain->uuid);
|
||||||
|
if (!vm) {
|
||||||
|
virUUIDFormat(domain->uuid, uuidstr);
|
||||||
|
virReportError(VIR_ERR_NO_DOMAIN,
|
||||||
|
_("no domain with matching uuid '%s' (%s)"),
|
||||||
|
uuidstr, domain->name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return vm;
|
||||||
|
}
|
||||||
|
@ -99,3 +99,6 @@ virCHDomainHasVcpuPids(virDomainObj *vm);
|
|||||||
|
|
||||||
char *
|
char *
|
||||||
virCHDomainGetMachineName(virDomainObj *vm);
|
virCHDomainGetMachineName(virDomainObj *vm);
|
||||||
|
|
||||||
|
virDomainObj *
|
||||||
|
virCHDomainObjFromDomain(virDomainPtr domain);
|
||||||
|
@ -49,25 +49,6 @@ VIR_LOG_INIT("ch.ch_driver");
|
|||||||
|
|
||||||
virCHDriver *ch_driver = NULL;
|
virCHDriver *ch_driver = NULL;
|
||||||
|
|
||||||
static virDomainObj *
|
|
||||||
chDomObjFromDomain(virDomain *domain)
|
|
||||||
{
|
|
||||||
virDomainObj *vm;
|
|
||||||
virCHDriver *driver = domain->conn->privateData;
|
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
|
|
||||||
vm = virDomainObjListFindByUUID(driver->domains, domain->uuid);
|
|
||||||
if (!vm) {
|
|
||||||
virUUIDFormat(domain->uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
|
||||||
_("no domain with matching uuid '%s' (%s)"),
|
|
||||||
uuidstr, domain->name);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return vm;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Functions */
|
/* Functions */
|
||||||
static int
|
static int
|
||||||
chConnectURIProbe(char **uri)
|
chConnectURIProbe(char **uri)
|
||||||
@ -271,7 +252,7 @@ chDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
if (!(vm = chDomObjFromDomain(dom)))
|
if (!(vm = virCHDomainObjFromDomain(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||||
@ -349,7 +330,7 @@ chDomainUndefineFlags(virDomainPtr dom,
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
if (!(vm = chDomObjFromDomain(dom)))
|
if (!(vm = virCHDomainObjFromDomain(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainUndefineFlagsEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainUndefineFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||||
@ -387,7 +368,7 @@ static int chDomainIsActive(virDomainPtr dom)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
chDriverLock(driver);
|
chDriverLock(driver);
|
||||||
if (!(vm = chDomObjFromDomain(dom)))
|
if (!(vm = virCHDomainObjFromDomain(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainIsActiveEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainIsActiveEnsureACL(dom->conn, vm->def) < 0)
|
||||||
@ -412,7 +393,7 @@ chDomainShutdownFlags(virDomainPtr dom,
|
|||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN, -1);
|
virCheckFlags(VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN, -1);
|
||||||
|
|
||||||
if (!(vm = chDomObjFromDomain(dom)))
|
if (!(vm = virCHDomainObjFromDomain(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
priv = vm->privateData;
|
priv = vm->privateData;
|
||||||
@ -468,7 +449,7 @@ chDomainReboot(virDomainPtr dom, unsigned int flags)
|
|||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_REBOOT_ACPI_POWER_BTN, -1);
|
virCheckFlags(VIR_DOMAIN_REBOOT_ACPI_POWER_BTN, -1);
|
||||||
|
|
||||||
if (!(vm = chDomObjFromDomain(dom)))
|
if (!(vm = virCHDomainObjFromDomain(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
priv = vm->privateData;
|
priv = vm->privateData;
|
||||||
@ -517,7 +498,7 @@ chDomainSuspend(virDomainPtr dom)
|
|||||||
virDomainObj *vm;
|
virDomainObj *vm;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!(vm = chDomObjFromDomain(dom)))
|
if (!(vm = virCHDomainObjFromDomain(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
priv = vm->privateData;
|
priv = vm->privateData;
|
||||||
@ -562,7 +543,7 @@ chDomainResume(virDomainPtr dom)
|
|||||||
virDomainObj *vm;
|
virDomainObj *vm;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!(vm = chDomObjFromDomain(dom)))
|
if (!(vm = virCHDomainObjFromDomain(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
priv = vm->privateData;
|
priv = vm->privateData;
|
||||||
@ -618,7 +599,7 @@ chDomainDestroyFlags(virDomainPtr dom, unsigned int flags)
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
if (!(vm = chDomObjFromDomain(dom)))
|
if (!(vm = virCHDomainObjFromDomain(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||||
@ -742,7 +723,7 @@ chDomainGetState(virDomainPtr dom,
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
if (!(vm = chDomObjFromDomain(dom)))
|
if (!(vm = virCHDomainObjFromDomain(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainGetStateEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetStateEnsureACL(dom->conn, vm->def) < 0)
|
||||||
@ -765,7 +746,7 @@ static char *chDomainGetXMLDesc(virDomainPtr dom,
|
|||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_XML_COMMON_FLAGS, NULL);
|
virCheckFlags(VIR_DOMAIN_XML_COMMON_FLAGS, NULL);
|
||||||
|
|
||||||
if (!(vm = chDomObjFromDomain(dom)))
|
if (!(vm = virCHDomainObjFromDomain(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainGetXMLDescEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainGetXMLDescEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
@ -785,7 +766,7 @@ static int chDomainGetInfo(virDomainPtr dom,
|
|||||||
virDomainObj *vm;
|
virDomainObj *vm;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!(vm = chDomObjFromDomain(dom)))
|
if (!(vm = virCHDomainObjFromDomain(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainGetInfoEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetInfoEnsureACL(dom->conn, vm->def) < 0)
|
||||||
@ -820,7 +801,7 @@ chDomainOpenConsole(virDomainPtr dom,
|
|||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_CONSOLE_SAFE | VIR_DOMAIN_CONSOLE_FORCE, -1);
|
virCheckFlags(VIR_DOMAIN_CONSOLE_SAFE | VIR_DOMAIN_CONSOLE_FORCE, -1);
|
||||||
|
|
||||||
if (!(vm = chDomObjFromDomain(dom)))
|
if (!(vm = virCHDomainObjFromDomain(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0)
|
||||||
@ -954,7 +935,7 @@ chDomainGetVcpusFlags(virDomainPtr dom,
|
|||||||
VIR_DOMAIN_AFFECT_CONFIG |
|
VIR_DOMAIN_AFFECT_CONFIG |
|
||||||
VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_GUEST, -1);
|
VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_GUEST, -1);
|
||||||
|
|
||||||
if (!(vm = chDomObjFromDomain(dom)))
|
if (!(vm = virCHDomainObjFromDomain(dom)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virDomainGetVcpusFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainGetVcpusFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
@ -999,7 +980,7 @@ chDomainGetVcpuPinInfo(virDomain *dom,
|
|||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1);
|
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1);
|
||||||
|
|
||||||
if (!(vm = chDomObjFromDomain(dom)))
|
if (!(vm = virCHDomainObjFromDomain(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainGetVcpuPinInfoEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetVcpuPinInfoEnsureACL(dom->conn, vm->def) < 0)
|
||||||
@ -1110,7 +1091,7 @@ chDomainGetVcpus(virDomainPtr dom,
|
|||||||
virDomainObj *vm;
|
virDomainObj *vm;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!(vm = chDomObjFromDomain(dom)))
|
if (!(vm = virCHDomainObjFromDomain(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainGetVcpusEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetVcpusEnsureACL(dom->conn, vm->def) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user