mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
hyperv: ambiguous VM names will throw an error
Since Hyper-V allows multiple VMs to be created with the same name, some commands produce unpredictable results due to hypervDomainLookupByName's WMI query selecting the wrong domain. For example, this prevents `virsh dumpxml` from outputting XML for the wrong domain. Signed-off-by: Matt Coleman <matt@datto.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
a79ac43f04
commit
65e1b4fd26
@ -333,6 +333,7 @@ typedef enum {
|
||||
VIR_ERR_NO_NETWORK_PORT = 107, /* network port not found */
|
||||
VIR_ERR_NO_HOSTNAME = 108, /* no domain's hostname found */
|
||||
VIR_ERR_CHECKPOINT_INCONSISTENT = 109, /* checkpoint can't be used */
|
||||
VIR_ERR_MULTIPLE_DOMAINS = 110, /* more than one matching domain found */
|
||||
|
||||
# ifdef VIR_ENUM_SENTINELS
|
||||
VIR_ERR_NUMBER_LAST
|
||||
|
@ -1118,6 +1118,13 @@ hypervDomainLookupByName(virConnectPtr conn, const char *name)
|
||||
if (hypervGetVirtualSystemByName(priv, name, &computerSystem) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (computerSystem->next) {
|
||||
virReportError(VIR_ERR_MULTIPLE_DOMAINS,
|
||||
_("Multiple domains exist with the name '%s': repeat the request using a UUID"),
|
||||
name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
hypervMsvmComputerSystemToDomain(conn, computerSystem, &domain);
|
||||
|
||||
cleanup:
|
||||
|
@ -1229,8 +1229,10 @@ static const virErrorMsgTuple virErrorMsgStrings[] = {
|
||||
N_("no hostname found: %s") },
|
||||
[VIR_ERR_CHECKPOINT_INCONSISTENT] = {
|
||||
N_("checkpoint inconsistent"),
|
||||
N_("checkpoint inconsistent: %s")
|
||||
},
|
||||
N_("checkpoint inconsistent: %s") },
|
||||
[VIR_ERR_MULTIPLE_DOMAINS] = {
|
||||
N_("multiple matching domains found"),
|
||||
N_("multiple matching domains found: %s") },
|
||||
};
|
||||
|
||||
G_STATIC_ASSERT(G_N_ELEMENTS(virErrorMsgStrings) == VIR_ERR_NUMBER_LAST);
|
||||
|
Loading…
Reference in New Issue
Block a user