提交 3236da8b 编写于 作者: M Michal Privoznik

parallels: Introduce parallelsDomObjFromDomain()

This function is practically copied over from qemu driver. Its
only purpose in life is to lookup a domain object and print an
error if no object is found.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 859e6801
......@@ -30,9 +30,41 @@
#include "virjson.h"
#include "parallels_utils.h"
#include "virstring.h"
#include "datatypes.h"
#define VIR_FROM_THIS VIR_FROM_PARALLELS
/**
* parallelsDomObjFromDomain:
* @domain: Domain pointer that has to be looked up
*
* This function looks up @domain and returns the appropriate virDomainObjPtr
* that has to be unlocked by virObjectUnlock().
*
* Returns the domain object without incremented reference counter which is locked
* on success, NULL otherwise.
*/
virDomainObjPtr
parallelsDomObjFromDomain(virDomainPtr domain)
{
virDomainObjPtr vm;
parallelsConnPtr privconn = domain->conn->privateData;
char uuidstr[VIR_UUID_STRING_BUFLEN];
vm = virDomainObjListFindByUUID(privconn->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;
}
static int
parallelsDoCmdRun(char **outbuf, const char *binary, va_list list)
{
......
......@@ -91,6 +91,8 @@ virDrvOpenStatus parallelsNetworkOpen(virConnectPtr conn, unsigned int flags);
int parallelsNetworkClose(virConnectPtr conn);
extern virNetworkDriver parallelsNetworkDriver;
virDomainObjPtr parallelsDomObjFromDomain(virDomainPtr domain);
virJSONValuePtr parallelsParseOutput(const char *binary, ...)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_SENTINEL;
char * parallelsGetOutput(const char *binary, ...)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册