virGetDomain: Set domain ID too

So far our code is full of the following pattern:

  dom = virGetDomain(conn, name, uuid)
  if (dom)
      dom->id = 42;

There is no reasong why it couldn't be just:

  dom = virGetDomain(conn, name, uuid, id);

After all, client domain representation consists of tuple (name,
uuid, id).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik committed 2017-04-03 08:35:57 +02:00
1 parent f7ef0a5a91
commit 5683b21309
23 files changed
+130 -285

No files matched your search

+5 -10
View File
@@ -608,6 +608,7 @@ hypervMsvmComputerSystemToDomain(virConnectPtr conn,
virDomainPtr *domain)
{
unsigned char uuid[VIR_UUID_BUFLEN];
int id = -1;
if (domain == NULL || *domain != NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
@@ -621,18 +622,12 @@ hypervMsvmComputerSystemToDomain(virConnectPtr conn,
return -1;
}
*domain = virGetDomain(conn, computerSystem->data->ElementName, uuid);
if (hypervIsMsvmComputerSystemActive(computerSystem, NULL))
id = computerSystem->data->ProcessID;
if (*domain == NULL)
return -1;
*domain = virGetDomain(conn, computerSystem->data->ElementName, uuid, id);
if (hypervIsMsvmComputerSystemActive(computerSystem, NULL)) {
(*domain)->id = computerSystem->data->ProcessID;
} else {
(*domain)->id = -1;
}
return 0;
return *domain ? 0 : -1;
}
int