提交 5da9c980 编写于 作者: D Daniel P. Berrange

Introduce device aliases

This patch introduces the support for giving all devices a short,
unique name, henceforth known as a 'device alias'.  These aliases
are not set by the end user, instead being assigned by the hypervisor
if it decides it want to support this concept.

The QEMU driver sets them whenever using the -device arg syntax
and uses them for improved hotplug/hotunplug. it is the intent
that other APIs (block / interface stats & device hotplug) be
able to accept device alias names in the future.

The XML syntax is

   <alias name="video0"/>

This may appear in any type of device that supports device info.

* src/conf/domain_conf.c, src/conf/domain_conf.h: Add a 'alias'
  field to virDomainDeviceInfo struct & parse/format it in XML
* src/libvirt_private.syms: Export virDomainDefClearDeviceAliases
* src/qemu/qemu_conf.c: Replace use of "nic_name" field with the
  standard device alias
* src/qemu/qemu_driver.c: Clear device aliases at shutdown
上级 774c757e
...@@ -806,50 +806,61 @@ int virDomainDeviceInfoIsSet(virDomainDeviceInfoPtr info) ...@@ -806,50 +806,61 @@ int virDomainDeviceInfoIsSet(virDomainDeviceInfoPtr info)
{ {
if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
return 1; return 1;
if (info->alias)
return 1;
return 0; return 0;
} }
void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info) void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info)
{ {
VIR_FREE(info->alias);
memset(&info->addr, 0, sizeof(info->addr)); memset(&info->addr, 0, sizeof(info->addr));
info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE; info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE;
} }
static void virDomainDeviceInfoClearField(virDomainDeviceInfoPtr info) static void virDomainDeviceInfoClearField(virDomainDeviceInfoPtr info, int alias, int pciaddr)
{ {
if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { if (alias)
VIR_FREE(info->alias);
if (pciaddr &&
info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
memset(&info->addr, 0, sizeof(info->addr)); memset(&info->addr, 0, sizeof(info->addr));
info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE; info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE;
} }
} }
static void virDomainDefClearDeviceInfo(virDomainDefPtr def) static void virDomainDefClearDeviceInfo(virDomainDefPtr def, int alias, int pciaddr)
{ {
int i; int i;
for (i = 0; i < def->ndisks ; i++) for (i = 0; i < def->ndisks ; i++)
virDomainDeviceInfoClearField(&def->disks[i]->info); virDomainDeviceInfoClearField(&def->disks[i]->info, alias, pciaddr);
for (i = 0; i < def->nnets ; i++) for (i = 0; i < def->nnets ; i++)
virDomainDeviceInfoClearField(&def->nets[i]->info); virDomainDeviceInfoClearField(&def->nets[i]->info, alias, pciaddr);
for (i = 0; i < def->nsounds ; i++) for (i = 0; i < def->nsounds ; i++)
virDomainDeviceInfoClearField(&def->sounds[i]->info); virDomainDeviceInfoClearField(&def->sounds[i]->info, alias, pciaddr);
for (i = 0; i < def->nhostdevs ; i++) for (i = 0; i < def->nhostdevs ; i++)
virDomainDeviceInfoClearField(&def->hostdevs[i]->info); virDomainDeviceInfoClearField(&def->hostdevs[i]->info, alias, pciaddr);
for (i = 0; i < def->nvideos ; i++) for (i = 0; i < def->nvideos ; i++)
virDomainDeviceInfoClearField(&def->videos[i]->info); virDomainDeviceInfoClearField(&def->videos[i]->info, alias, pciaddr);
for (i = 0; i < def->ncontrollers ; i++) for (i = 0; i < def->ncontrollers ; i++)
virDomainDeviceInfoClearField(&def->controllers[i]->info); virDomainDeviceInfoClearField(&def->controllers[i]->info, alias, pciaddr);
if (def->watchdog) if (def->watchdog)
virDomainDeviceInfoClearField(&def->watchdog->info); virDomainDeviceInfoClearField(&def->watchdog->info, alias, pciaddr);
} }
void virDomainDefClearPCIAddresses(virDomainDefPtr def) void virDomainDefClearPCIAddresses(virDomainDefPtr def)
{ {
virDomainDefClearDeviceInfo(def); virDomainDefClearDeviceInfo(def, 0, 1);
}
void virDomainDefClearDeviceAliases(virDomainDefPtr def)
{
virDomainDefClearDeviceInfo(def, 1, 0);
} }
...@@ -857,7 +868,8 @@ void virDomainDefClearPCIAddresses(virDomainDefPtr def) ...@@ -857,7 +868,8 @@ void virDomainDefClearPCIAddresses(virDomainDefPtr def)
* @param address Device address to stringify * @param address Device address to stringify
*/ */
static int virDomainDeviceInfoFormat(virBufferPtr buf, static int virDomainDeviceInfoFormat(virBufferPtr buf,
virDomainDeviceInfoPtr info) virDomainDeviceInfoPtr info,
int flags)
{ {
if (!info) { if (!info) {
virDomainReportError(NULL, VIR_ERR_INTERNAL_ERROR, "%s", virDomainReportError(NULL, VIR_ERR_INTERNAL_ERROR, "%s",
...@@ -865,6 +877,11 @@ static int virDomainDeviceInfoFormat(virBufferPtr buf, ...@@ -865,6 +877,11 @@ static int virDomainDeviceInfoFormat(virBufferPtr buf,
return -1; return -1;
} }
if (info->alias &&
!(flags & VIR_DOMAIN_XML_INACTIVE)) {
virBufferVSprintf(buf, " <alias name='%s'/>\n", info->alias);
}
if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
return 0; return 0;
...@@ -1044,10 +1061,11 @@ static int ...@@ -1044,10 +1061,11 @@ static int
virDomainDeviceInfoParseXML(virConnectPtr conn, virDomainDeviceInfoParseXML(virConnectPtr conn,
xmlNodePtr node, xmlNodePtr node,
virDomainDeviceInfoPtr info, virDomainDeviceInfoPtr info,
unsigned int flags ATTRIBUTE_UNUSED) int flags)
{ {
xmlNodePtr cur; xmlNodePtr cur;
xmlNodePtr address = NULL; xmlNodePtr address = NULL;
xmlNodePtr alias = NULL;
char *type = NULL; char *type = NULL;
int ret = -1; int ret = -1;
...@@ -1056,7 +1074,11 @@ virDomainDeviceInfoParseXML(virConnectPtr conn, ...@@ -1056,7 +1074,11 @@ virDomainDeviceInfoParseXML(virConnectPtr conn,
cur = node->children; cur = node->children;
while (cur != NULL) { while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) { if (cur->type == XML_ELEMENT_NODE) {
if (address == NULL && if (alias == NULL &&
!(flags & VIR_DOMAIN_XML_INACTIVE) &&
xmlStrEqual(cur->name, BAD_CAST "alias")) {
alias = cur;
} else if (address == NULL &&
xmlStrEqual(cur->name, BAD_CAST "address")) { xmlStrEqual(cur->name, BAD_CAST "address")) {
address = cur; address = cur;
} }
...@@ -1064,6 +1086,9 @@ virDomainDeviceInfoParseXML(virConnectPtr conn, ...@@ -1064,6 +1086,9 @@ virDomainDeviceInfoParseXML(virConnectPtr conn,
cur = cur->next; cur = cur->next;
} }
if (alias)
info->alias = virXMLPropString(alias, "name");
if (!address) if (!address)
return 0; return 0;
...@@ -1102,6 +1127,8 @@ virDomainDeviceInfoParseXML(virConnectPtr conn, ...@@ -1102,6 +1127,8 @@ virDomainDeviceInfoParseXML(virConnectPtr conn,
ret = 0; ret = 0;
cleanup: cleanup:
if (ret == -1)
VIR_FREE(info->alias);
VIR_FREE(type); VIR_FREE(type);
return ret; return ret;
} }
...@@ -1666,6 +1693,8 @@ virDomainNetDefParseXML(virConnectPtr conn, ...@@ -1666,6 +1693,8 @@ virDomainNetDefParseXML(virConnectPtr conn,
goto error; goto error;
} }
def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
def->info.alias = nic_name;
nic_name = NULL;
} else { } else {
if (virDomainDeviceInfoParseXML(conn, node, &def->info, flags) < 0) if (virDomainDeviceInfoParseXML(conn, node, &def->info, flags) < 0)
goto error; goto error;
...@@ -1680,9 +1709,8 @@ virDomainNetDefParseXML(virConnectPtr conn, ...@@ -1680,9 +1709,8 @@ virDomainNetDefParseXML(virConnectPtr conn,
goto error; goto error;
} }
def->nic_name = nic_name;
def->hostnet_name = hostnet_name; def->hostnet_name = hostnet_name;
nic_name = hostnet_name = NULL; hostnet_name = NULL;
def->vlan = -1; def->vlan = -1;
if (vlan && virStrToLong_i(vlan, NULL, 10, &def->vlan) < 0) { if (vlan && virStrToLong_i(vlan, NULL, 10, &def->vlan) < 0) {
...@@ -2930,6 +2958,10 @@ virDomainHostdevDefParseXML(virConnectPtr conn, ...@@ -2930,6 +2958,10 @@ virDomainHostdevDefParseXML(virConnectPtr conn,
if (virDomainHostdevSubsysPciDefParseXML(conn, cur, def, flags) < 0) if (virDomainHostdevSubsysPciDefParseXML(conn, cur, def, flags) < 0)
goto error; goto error;
} }
} else if (xmlStrEqual(cur->name, BAD_CAST "address")) {
} else {
virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("unknown node %s"), cur->name);
} }
} }
cur = cur->next; cur = cur->next;
...@@ -4499,7 +4531,8 @@ virDomainLifecycleDefFormat(virConnectPtr conn, ...@@ -4499,7 +4531,8 @@ virDomainLifecycleDefFormat(virConnectPtr conn,
static int static int
virDomainDiskDefFormat(virConnectPtr conn, virDomainDiskDefFormat(virConnectPtr conn,
virBufferPtr buf, virBufferPtr buf,
virDomainDiskDefPtr def) virDomainDiskDefPtr def,
int flags)
{ {
const char *type = virDomainDiskTypeToString(def->type); const char *type = virDomainDiskTypeToString(def->type);
const char *device = virDomainDiskDeviceTypeToString(def->device); const char *device = virDomainDiskDeviceTypeToString(def->device);
...@@ -4576,7 +4609,7 @@ virDomainDiskDefFormat(virConnectPtr conn, ...@@ -4576,7 +4609,7 @@ virDomainDiskDefFormat(virConnectPtr conn,
virStorageEncryptionFormat(conn, buf, def->encryption) < 0) virStorageEncryptionFormat(conn, buf, def->encryption) < 0)
return -1; return -1;
if (virDomainDeviceInfoFormat(buf, &def->info) < 0) if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
return -1; return -1;
virBufferAddLit(buf, " </disk>\n"); virBufferAddLit(buf, " </disk>\n");
...@@ -4587,7 +4620,8 @@ virDomainDiskDefFormat(virConnectPtr conn, ...@@ -4587,7 +4620,8 @@ virDomainDiskDefFormat(virConnectPtr conn,
static int static int
virDomainControllerDefFormat(virConnectPtr conn, virDomainControllerDefFormat(virConnectPtr conn,
virBufferPtr buf, virBufferPtr buf,
virDomainControllerDefPtr def) virDomainControllerDefPtr def,
int flags)
{ {
const char *type = virDomainControllerTypeToString(def->type); const char *type = virDomainControllerTypeToString(def->type);
...@@ -4603,7 +4637,7 @@ virDomainControllerDefFormat(virConnectPtr conn, ...@@ -4603,7 +4637,7 @@ virDomainControllerDefFormat(virConnectPtr conn,
if (virDomainDeviceInfoIsSet(&def->info)) { if (virDomainDeviceInfoIsSet(&def->info)) {
virBufferAddLit(buf, ">\n"); virBufferAddLit(buf, ">\n");
if (virDomainDeviceInfoFormat(buf, &def->info) < 0) if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
return -1; return -1;
virBufferAddLit(buf, " </controller>\n"); virBufferAddLit(buf, " </controller>\n");
} else { } else {
...@@ -4749,7 +4783,7 @@ virDomainNetDefFormat(virConnectPtr conn, ...@@ -4749,7 +4783,7 @@ virDomainNetDefFormat(virConnectPtr conn,
virBufferAddLit(buf, "/>\n"); virBufferAddLit(buf, "/>\n");
} }
if (virDomainDeviceInfoFormat(buf, &def->info) < 0) if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
return -1; return -1;
virBufferAddLit(buf, " </interface>\n"); virBufferAddLit(buf, " </interface>\n");
...@@ -4912,7 +4946,8 @@ cleanup: ...@@ -4912,7 +4946,8 @@ cleanup:
static int static int
virDomainSoundDefFormat(virConnectPtr conn, virDomainSoundDefFormat(virConnectPtr conn,
virBufferPtr buf, virBufferPtr buf,
virDomainSoundDefPtr def) virDomainSoundDefPtr def,
int flags)
{ {
const char *model = virDomainSoundModelTypeToString(def->model); const char *model = virDomainSoundModelTypeToString(def->model);
...@@ -4927,7 +4962,7 @@ virDomainSoundDefFormat(virConnectPtr conn, ...@@ -4927,7 +4962,7 @@ virDomainSoundDefFormat(virConnectPtr conn,
if (virDomainDeviceInfoIsSet(&def->info)) { if (virDomainDeviceInfoIsSet(&def->info)) {
virBufferAddLit(buf, ">\n"); virBufferAddLit(buf, ">\n");
if (virDomainDeviceInfoFormat(buf, &def->info) < 0) if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
return -1; return -1;
virBufferAddLit(buf, " </sound>\n"); virBufferAddLit(buf, " </sound>\n");
} else { } else {
...@@ -4941,7 +4976,8 @@ virDomainSoundDefFormat(virConnectPtr conn, ...@@ -4941,7 +4976,8 @@ virDomainSoundDefFormat(virConnectPtr conn,
static int static int
virDomainWatchdogDefFormat(virConnectPtr conn, virDomainWatchdogDefFormat(virConnectPtr conn,
virBufferPtr buf, virBufferPtr buf,
virDomainWatchdogDefPtr def) virDomainWatchdogDefPtr def,
int flags)
{ {
const char *model = virDomainWatchdogModelTypeToString (def->model); const char *model = virDomainWatchdogModelTypeToString (def->model);
const char *action = virDomainWatchdogActionTypeToString (def->action); const char *action = virDomainWatchdogActionTypeToString (def->action);
...@@ -4963,7 +4999,7 @@ virDomainWatchdogDefFormat(virConnectPtr conn, ...@@ -4963,7 +4999,7 @@ virDomainWatchdogDefFormat(virConnectPtr conn,
if (virDomainDeviceInfoIsSet(&def->info)) { if (virDomainDeviceInfoIsSet(&def->info)) {
virBufferAddLit(buf, ">\n"); virBufferAddLit(buf, ">\n");
if (virDomainDeviceInfoFormat(buf, &def->info) < 0) if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
return -1; return -1;
virBufferAddLit(buf, " </watchdog>\n"); virBufferAddLit(buf, " </watchdog>\n");
} else { } else {
...@@ -4989,7 +5025,8 @@ virDomainVideoAccelDefFormat(virBufferPtr buf, ...@@ -4989,7 +5025,8 @@ virDomainVideoAccelDefFormat(virBufferPtr buf,
static int static int
virDomainVideoDefFormat(virConnectPtr conn, virDomainVideoDefFormat(virConnectPtr conn,
virBufferPtr buf, virBufferPtr buf,
virDomainVideoDefPtr def) virDomainVideoDefPtr def,
int flags)
{ {
const char *model = virDomainVideoTypeToString(def->type); const char *model = virDomainVideoTypeToString(def->type);
...@@ -5014,7 +5051,7 @@ virDomainVideoDefFormat(virConnectPtr conn, ...@@ -5014,7 +5051,7 @@ virDomainVideoDefFormat(virConnectPtr conn,
virBufferAddLit(buf, "/>\n"); virBufferAddLit(buf, "/>\n");
} }
if (virDomainDeviceInfoFormat(buf, &def->info) < 0) if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
return -1; return -1;
virBufferAddLit(buf, " </video>\n"); virBufferAddLit(buf, " </video>\n");
...@@ -5146,7 +5183,8 @@ virDomainGraphicsDefFormat(virConnectPtr conn, ...@@ -5146,7 +5183,8 @@ virDomainGraphicsDefFormat(virConnectPtr conn,
static int static int
virDomainHostdevDefFormat(virConnectPtr conn, virDomainHostdevDefFormat(virConnectPtr conn,
virBufferPtr buf, virBufferPtr buf,
virDomainHostdevDefPtr def) virDomainHostdevDefPtr def,
int flags)
{ {
const char *mode = virDomainHostdevModeTypeToString(def->mode); const char *mode = virDomainHostdevModeTypeToString(def->mode);
const char *type; const char *type;
...@@ -5190,7 +5228,7 @@ virDomainHostdevDefFormat(virConnectPtr conn, ...@@ -5190,7 +5228,7 @@ virDomainHostdevDefFormat(virConnectPtr conn,
virBufferAddLit(buf, " </source>\n"); virBufferAddLit(buf, " </source>\n");
if (virDomainDeviceInfoFormat(buf, &def->info) < 0) if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
return -1; return -1;
virBufferAddLit(buf, " </hostdev>\n"); virBufferAddLit(buf, " </hostdev>\n");
...@@ -5357,11 +5395,11 @@ char *virDomainDefFormat(virConnectPtr conn, ...@@ -5357,11 +5395,11 @@ char *virDomainDefFormat(virConnectPtr conn,
def->emulator); def->emulator);
for (n = 0 ; n < def->ndisks ; n++) for (n = 0 ; n < def->ndisks ; n++)
if (virDomainDiskDefFormat(conn, &buf, def->disks[n]) < 0) if (virDomainDiskDefFormat(conn, &buf, def->disks[n], flags) < 0)
goto cleanup; goto cleanup;
for (n = 0 ; n < def->ncontrollers ; n++) for (n = 0 ; n < def->ncontrollers ; n++)
if (virDomainControllerDefFormat(conn, &buf, def->controllers[n]) < 0) if (virDomainControllerDefFormat(conn, &buf, def->controllers[n], flags) < 0)
goto cleanup; goto cleanup;
for (n = 0 ; n < def->nfss ; n++) for (n = 0 ; n < def->nfss ; n++)
...@@ -5421,19 +5459,19 @@ char *virDomainDefFormat(virConnectPtr conn, ...@@ -5421,19 +5459,19 @@ char *virDomainDefFormat(virConnectPtr conn,
} }
for (n = 0 ; n < def->nsounds ; n++) for (n = 0 ; n < def->nsounds ; n++)
if (virDomainSoundDefFormat(conn, &buf, def->sounds[n]) < 0) if (virDomainSoundDefFormat(conn, &buf, def->sounds[n], flags) < 0)
goto cleanup; goto cleanup;
for (n = 0 ; n < def->nvideos ; n++) for (n = 0 ; n < def->nvideos ; n++)
if (virDomainVideoDefFormat(conn, &buf, def->videos[n]) < 0) if (virDomainVideoDefFormat(conn, &buf, def->videos[n], flags) < 0)
goto cleanup; goto cleanup;
for (n = 0 ; n < def->nhostdevs ; n++) for (n = 0 ; n < def->nhostdevs ; n++)
if (virDomainHostdevDefFormat(conn, &buf, def->hostdevs[n]) < 0) if (virDomainHostdevDefFormat(conn, &buf, def->hostdevs[n], flags) < 0)
goto cleanup; goto cleanup;
if (def->watchdog) if (def->watchdog)
virDomainWatchdogDefFormat (conn, &buf, def->watchdog); virDomainWatchdogDefFormat (conn, &buf, def->watchdog, flags);
virBufferAddLit(&buf, " </devices>\n"); virBufferAddLit(&buf, " </devices>\n");
......
...@@ -92,6 +92,7 @@ struct _virDomainDeviceDriveAddress { ...@@ -92,6 +92,7 @@ struct _virDomainDeviceDriveAddress {
typedef struct _virDomainDeviceInfo virDomainDeviceInfo; typedef struct _virDomainDeviceInfo virDomainDeviceInfo;
typedef virDomainDeviceInfo *virDomainDeviceInfoPtr; typedef virDomainDeviceInfo *virDomainDeviceInfoPtr;
struct _virDomainDeviceInfo { struct _virDomainDeviceInfo {
char *alias;
int type; int type;
union { union {
virDomainDevicePCIAddress pci; virDomainDevicePCIAddress pci;
...@@ -246,8 +247,6 @@ struct _virDomainNetDef { ...@@ -246,8 +247,6 @@ struct _virDomainNetDef {
char *ifname; char *ifname;
virDomainDeviceInfo info; virDomainDeviceInfo info;
/* XXX figure out how to remove this */ /* XXX figure out how to remove this */
char *nic_name;
/* XXX figure out how to remove this */
char *hostnet_name; char *hostnet_name;
/* XXX figure out how to remove this */ /* XXX figure out how to remove this */
int vlan; int vlan;
...@@ -737,6 +736,7 @@ int virDomainDeviceDriveAddressIsValid(virDomainDeviceDriveAddressPtr addr); ...@@ -737,6 +736,7 @@ int virDomainDeviceDriveAddressIsValid(virDomainDeviceDriveAddressPtr addr);
int virDomainDeviceInfoIsSet(virDomainDeviceInfoPtr info); int virDomainDeviceInfoIsSet(virDomainDeviceInfoPtr info);
void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info); void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info);
void virDomainDefClearPCIAddresses(virDomainDefPtr def); void virDomainDefClearPCIAddresses(virDomainDefPtr def);
void virDomainDefClearDeviceAliases(virDomainDefPtr def);
void virDomainDefFree(virDomainDefPtr vm); void virDomainDefFree(virDomainDefPtr vm);
void virDomainObjRef(virDomainObjPtr vm); void virDomainObjRef(virDomainObjPtr vm);
......
...@@ -188,6 +188,7 @@ virDomainControllerDefFree; ...@@ -188,6 +188,7 @@ virDomainControllerDefFree;
virDomainDeviceAddressTypeToString; virDomainDeviceAddressTypeToString;
virDomainDefAddDiskControllers; virDomainDefAddDiskControllers;
virDomainDefClearPCIAddresses; virDomainDefClearPCIAddresses;
virDomainDefClearDeviceAliases;
# domain_event.h # domain_event.h
......
...@@ -1489,7 +1489,7 @@ qemuAssignNetNames(virDomainDefPtr def, ...@@ -1489,7 +1489,7 @@ qemuAssignNetNames(virDomainDefPtr def,
if (def->nets[i] == net) if (def->nets[i] == net)
continue; continue;
if (!def->nets[i]->nic_name || !def->nets[i]->hostnet_name) if (!def->nets[i]->info.alias || !def->nets[i]->hostnet_name)
continue; continue;
if ((def->nets[i]->model == NULL && net->model == NULL) || if ((def->nets[i]->model == NULL && net->model == NULL) ||
...@@ -1517,7 +1517,7 @@ qemuAssignNetNames(virDomainDefPtr def, ...@@ -1517,7 +1517,7 @@ qemuAssignNetNames(virDomainDefPtr def,
return -1; return -1;
} }
net->nic_name = nic_name; net->info.alias = nic_name;
net->hostnet_name = hostnet_name; net->hostnet_name = hostnet_name;
return 0; return 0;
...@@ -1714,8 +1714,8 @@ qemuBuildNicStr(virConnectPtr conn, ...@@ -1714,8 +1714,8 @@ qemuBuildNicStr(virConnectPtr conn,
vlan, vlan,
(net->model ? ",model=" : ""), (net->model ? ",model=" : ""),
(net->model ? net->model : ""), (net->model ? net->model : ""),
(net->nic_name ? ",name=" : ""), (net->info.alias ? ",name=" : ""),
(net->nic_name ? net->nic_name : "")) < 0) { (net->info.alias ? net->info.alias : "")) < 0) {
virReportOOMError(conn); virReportOOMError(conn);
return -1; return -1;
} }
......
...@@ -3049,6 +3049,7 @@ static void qemudShutdownVMDaemon(virConnectPtr conn, ...@@ -3049,6 +3049,7 @@ static void qemudShutdownVMDaemon(virConnectPtr conn,
} }
virDomainDefClearPCIAddresses(vm->def); virDomainDefClearPCIAddresses(vm->def);
virDomainDefClearDeviceAliases(vm->def);
if (qemuDomainSetAllDeviceOwnership(conn, driver, vm->def, 1) < 0) if (qemuDomainSetAllDeviceOwnership(conn, driver, vm->def, 1) < 0)
VIR_WARN("Failed to restore all device ownership for %s", VIR_WARN("Failed to restore all device ownership for %s",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册