mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
conf: put all guest-related HostdevDef data in one object
To help consolidate the commonality between virDomainHostdevDef and virDomainNetDef into as few members as possible (and because I think it makes sense), this patch moves the rombar and bootIndex members into the "info" member that is common to both (and to all the other structs that use them). It's a bit problematic that this gives rombar and bootIndex to many device types that don't use them, but this is already the case for the master and mastertype members of virDomainDeviceInfo, and is properly commented as such in the definition. Note that this opens the door to supporting rombar for other devices that are attached to the guest PCI bus - virtio-blk-pci, virtio-net-pci, various other network adapters - which which have that capability in qemu, but previously had no support in libvirt.
This commit is contained in:
parent
aaa6210f81
commit
159f4d0b30
@ -3022,7 +3022,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
|
|||||||
(xmlStrEqual(cur->name, BAD_CAST "serial"))) {
|
(xmlStrEqual(cur->name, BAD_CAST "serial"))) {
|
||||||
serial = (char *)xmlNodeGetContent(cur);
|
serial = (char *)xmlNodeGetContent(cur);
|
||||||
} else if (xmlStrEqual(cur->name, BAD_CAST "boot")) {
|
} else if (xmlStrEqual(cur->name, BAD_CAST "boot")) {
|
||||||
if (virDomainDeviceBootParseXML(cur, &def->bootIndex,
|
if (virDomainDeviceBootParseXML(cur, &def->info.bootIndex,
|
||||||
bootMap))
|
bootMap))
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -3791,7 +3791,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
|
|||||||
/* Legacy back-compat. Don't add any more attributes here */
|
/* Legacy back-compat. Don't add any more attributes here */
|
||||||
devaddr = virXMLPropString(cur, "devaddr");
|
devaddr = virXMLPropString(cur, "devaddr");
|
||||||
} else if (xmlStrEqual(cur->name, BAD_CAST "boot")) {
|
} else if (xmlStrEqual(cur->name, BAD_CAST "boot")) {
|
||||||
if (virDomainDeviceBootParseXML(cur, &def->bootIndex,
|
if (virDomainDeviceBootParseXML(cur, &def->info.bootIndex,
|
||||||
bootMap))
|
bootMap))
|
||||||
goto error;
|
goto error;
|
||||||
} else if ((actual == NULL) &&
|
} else if ((actual == NULL) &&
|
||||||
@ -6230,7 +6230,7 @@ virDomainHostdevDefParseXML(const xmlNodePtr node,
|
|||||||
} else if (xmlStrEqual(cur->name, BAD_CAST "alias")) {
|
} else if (xmlStrEqual(cur->name, BAD_CAST "alias")) {
|
||||||
/* alias is parsed as part of virDomainDeviceInfoParseXML */
|
/* alias is parsed as part of virDomainDeviceInfoParseXML */
|
||||||
} else if (xmlStrEqual(cur->name, BAD_CAST "boot")) {
|
} else if (xmlStrEqual(cur->name, BAD_CAST "boot")) {
|
||||||
if (virDomainDeviceBootParseXML(cur, &def->bootIndex,
|
if (virDomainDeviceBootParseXML(cur, &def->info.bootIndex,
|
||||||
bootMap))
|
bootMap))
|
||||||
goto error;
|
goto error;
|
||||||
} else if (xmlStrEqual(cur->name, BAD_CAST "rom")) {
|
} else if (xmlStrEqual(cur->name, BAD_CAST "rom")) {
|
||||||
@ -6240,7 +6240,7 @@ virDomainHostdevDefParseXML(const xmlNodePtr node,
|
|||||||
"%s", _("missing rom bar attribute"));
|
"%s", _("missing rom bar attribute"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if ((def->rombar = virDomainPciRombarModeTypeFromString(rombar)) <= 0) {
|
if ((def->info.rombar = virDomainPciRombarModeTypeFromString(rombar)) <= 0) {
|
||||||
virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown rom bar value '%s'"), rombar);
|
_("unknown rom bar value '%s'"), rombar);
|
||||||
VIR_FREE(rombar);
|
VIR_FREE(rombar);
|
||||||
@ -10089,8 +10089,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
|
|||||||
virBufferAddLit(buf, " </iotune>\n");
|
virBufferAddLit(buf, " </iotune>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->bootIndex)
|
if (def->info.bootIndex)
|
||||||
virBufferAsprintf(buf, " <boot order='%d'/>\n", def->bootIndex);
|
virBufferAsprintf(buf, " <boot order='%d'/>\n", def->info.bootIndex);
|
||||||
if (def->readonly)
|
if (def->readonly)
|
||||||
virBufferAddLit(buf, " <readonly/>\n");
|
virBufferAddLit(buf, " <readonly/>\n");
|
||||||
if (def->shared)
|
if (def->shared)
|
||||||
@ -10454,8 +10454,8 @@ virDomainNetDefFormat(virBufferPtr buf,
|
|||||||
return -1;
|
return -1;
|
||||||
virBufferAdjustIndent(buf, -6);
|
virBufferAdjustIndent(buf, -6);
|
||||||
}
|
}
|
||||||
if (def->bootIndex)
|
if (def->info.bootIndex)
|
||||||
virBufferAsprintf(buf, " <boot order='%d'/>\n", def->bootIndex);
|
virBufferAsprintf(buf, " <boot order='%d'/>\n", def->info.bootIndex);
|
||||||
|
|
||||||
if (def->tune.sndbuf_specified) {
|
if (def->tune.sndbuf_specified) {
|
||||||
virBufferAddLit(buf, " <tune>\n");
|
virBufferAddLit(buf, " <tune>\n");
|
||||||
@ -11305,19 +11305,19 @@ virDomainHostdevDefFormat(virBufferPtr buf,
|
|||||||
|
|
||||||
virBufferAddLit(buf, " </source>\n");
|
virBufferAddLit(buf, " </source>\n");
|
||||||
|
|
||||||
if (def->bootIndex)
|
if (def->info.bootIndex)
|
||||||
virBufferAsprintf(buf, " <boot order='%d'/>\n", def->bootIndex);
|
virBufferAsprintf(buf, " <boot order='%d'/>\n", def->info.bootIndex);
|
||||||
|
|
||||||
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
|
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (def->rombar) {
|
if (def->info.rombar) {
|
||||||
const char *rombar
|
const char *rombar
|
||||||
= virDomainPciRombarModeTypeToString(def->rombar);
|
= virDomainPciRombarModeTypeToString(def->info.rombar);
|
||||||
if (!rombar) {
|
if (!rombar) {
|
||||||
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
|
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unexpected rom bar value %d"),
|
_("unexpected rom bar value %d"),
|
||||||
def->rombar);
|
def->info.rombar);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
virBufferAsprintf(buf, " <rom bar='%s'/>\n", rombar);
|
virBufferAsprintf(buf, " <rom bar='%s'/>\n", rombar);
|
||||||
|
@ -82,6 +82,14 @@ enum virDomainDeviceAddressPciMulti {
|
|||||||
VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_LAST
|
VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum virDomainPciRombarMode {
|
||||||
|
VIR_DOMAIN_PCI_ROMBAR_DEFAULT = 0,
|
||||||
|
VIR_DOMAIN_PCI_ROMBAR_ON,
|
||||||
|
VIR_DOMAIN_PCI_ROMBAR_OFF,
|
||||||
|
|
||||||
|
VIR_DOMAIN_PCI_ROMBAR_LAST
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct _virDomainDevicePCIAddress virDomainDevicePCIAddress;
|
typedef struct _virDomainDevicePCIAddress virDomainDevicePCIAddress;
|
||||||
typedef virDomainDevicePCIAddress *virDomainDevicePCIAddressPtr;
|
typedef virDomainDevicePCIAddress *virDomainDevicePCIAddressPtr;
|
||||||
struct _virDomainDevicePCIAddress {
|
struct _virDomainDevicePCIAddress {
|
||||||
@ -159,6 +167,10 @@ struct _virDomainDeviceInfo {
|
|||||||
union {
|
union {
|
||||||
virDomainDeviceUSBMaster usb;
|
virDomainDeviceUSBMaster usb;
|
||||||
} master;
|
} master;
|
||||||
|
/* rombar is only used for pci hostdev devices, and bootIndex only
|
||||||
|
* for disk, network interface, and hostdev devices */
|
||||||
|
int rombar; /* enum virDomainPciRombarMode */
|
||||||
|
int bootIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum virDomainSeclabelType {
|
enum virDomainSeclabelType {
|
||||||
@ -389,7 +401,6 @@ struct _virDomainDiskDef {
|
|||||||
int cachemode;
|
int cachemode;
|
||||||
int error_policy; /* enum virDomainDiskErrorPolicy */
|
int error_policy; /* enum virDomainDiskErrorPolicy */
|
||||||
int rerror_policy; /* enum virDomainDiskErrorPolicy */
|
int rerror_policy; /* enum virDomainDiskErrorPolicy */
|
||||||
int bootIndex;
|
|
||||||
int iomode;
|
int iomode;
|
||||||
int ioeventfd;
|
int ioeventfd;
|
||||||
int event_idx;
|
int event_idx;
|
||||||
@ -635,7 +646,6 @@ struct _virDomainNetDef {
|
|||||||
} tune;
|
} tune;
|
||||||
char *script;
|
char *script;
|
||||||
char *ifname;
|
char *ifname;
|
||||||
int bootIndex;
|
|
||||||
virDomainDeviceInfo info;
|
virDomainDeviceInfo info;
|
||||||
char *filter;
|
char *filter;
|
||||||
virNWFilterHashTablePtr filterparams;
|
virNWFilterHashTablePtr filterparams;
|
||||||
@ -1074,14 +1084,6 @@ enum virDomainHostdevSubsysType {
|
|||||||
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST
|
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
enum virDomainPciRombarMode {
|
|
||||||
VIR_DOMAIN_PCI_ROMBAR_DEFAULT = 0,
|
|
||||||
VIR_DOMAIN_PCI_ROMBAR_ON,
|
|
||||||
VIR_DOMAIN_PCI_ROMBAR_OFF,
|
|
||||||
|
|
||||||
VIR_DOMAIN_PCI_ROMBAR_LAST
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct _virDomainHostdevDef virDomainHostdevDef;
|
typedef struct _virDomainHostdevDef virDomainHostdevDef;
|
||||||
typedef virDomainHostdevDef *virDomainHostdevDefPtr;
|
typedef virDomainHostdevDef *virDomainHostdevDefPtr;
|
||||||
struct _virDomainHostdevDef {
|
struct _virDomainHostdevDef {
|
||||||
@ -1108,9 +1110,7 @@ struct _virDomainHostdevDef {
|
|||||||
int dummy;
|
int dummy;
|
||||||
} caps;
|
} caps;
|
||||||
} source;
|
} source;
|
||||||
int bootIndex;
|
|
||||||
virDomainDeviceInfo info; /* Guest address */
|
virDomainDeviceInfo info; /* Guest address */
|
||||||
int rombar; /* enum virDomainPciRombarMode */
|
|
||||||
virDomainHostdevOrigStates origstates;
|
virDomainHostdevOrigStates origstates;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2849,19 +2849,19 @@ qemuBuildPCIHostdevDevStr(virDomainHostdevDefPtr dev, const char *configfd,
|
|||||||
virBufferAsprintf(&buf, ",id=%s", dev->info.alias);
|
virBufferAsprintf(&buf, ",id=%s", dev->info.alias);
|
||||||
if (configfd && *configfd)
|
if (configfd && *configfd)
|
||||||
virBufferAsprintf(&buf, ",configfd=%s", configfd);
|
virBufferAsprintf(&buf, ",configfd=%s", configfd);
|
||||||
if (dev->bootIndex)
|
if (dev->info.bootIndex)
|
||||||
virBufferAsprintf(&buf, ",bootindex=%d", dev->bootIndex);
|
virBufferAsprintf(&buf, ",bootindex=%d", dev->info.bootIndex);
|
||||||
if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps) < 0)
|
if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (dev->rombar) {
|
if (dev->info.rombar) {
|
||||||
if (!qemuCapsGet(qemuCaps, QEMU_CAPS_PCI_ROMBAR)) {
|
if (!qemuCapsGet(qemuCaps, QEMU_CAPS_PCI_ROMBAR)) {
|
||||||
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
"%s", _("rombar not supported in this QEMU binary"));
|
"%s", _("rombar not supported in this QEMU binary"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (dev->rombar) {
|
switch (dev->info.rombar) {
|
||||||
case VIR_DOMAIN_PCI_ROMBAR_OFF:
|
case VIR_DOMAIN_PCI_ROMBAR_OFF:
|
||||||
virBufferAddLit(&buf, ",rombar=0");
|
virBufferAddLit(&buf, ",rombar=0");
|
||||||
break;
|
break;
|
||||||
@ -4448,8 +4448,8 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
|
|
||||||
if (!emitBootindex)
|
if (!emitBootindex)
|
||||||
bootindex = 0;
|
bootindex = 0;
|
||||||
else if (disk->bootIndex)
|
else if (disk->info.bootIndex)
|
||||||
bootindex = disk->bootIndex;
|
bootindex = disk->info.bootIndex;
|
||||||
|
|
||||||
if (withDeviceArg) {
|
if (withDeviceArg) {
|
||||||
if (disk->bus == VIR_DOMAIN_DISK_BUS_FDC) {
|
if (disk->bus == VIR_DOMAIN_DISK_BUS_FDC) {
|
||||||
@ -4643,7 +4643,7 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
|
|
||||||
bootNet = 0;
|
bootNet = 0;
|
||||||
if (!bootindex)
|
if (!bootindex)
|
||||||
bootindex = net->bootIndex;
|
bootindex = net->info.bootIndex;
|
||||||
|
|
||||||
/* VLANs are not used with -netdev, so don't record them */
|
/* VLANs are not used with -netdev, so don't record them */
|
||||||
if (qemuCapsGet(qemuCaps, QEMU_CAPS_NETDEV) &&
|
if (qemuCapsGet(qemuCaps, QEMU_CAPS_NETDEV) &&
|
||||||
@ -5576,7 +5576,7 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
virDomainHostdevDefPtr hostdev = def->hostdevs[i];
|
virDomainHostdevDefPtr hostdev = def->hostdevs[i];
|
||||||
char *devstr;
|
char *devstr;
|
||||||
|
|
||||||
if (hostdev->bootIndex) {
|
if (hostdev->info.bootIndex) {
|
||||||
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
|
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
|
||||||
hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
|
hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
|
||||||
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
@ -4518,7 +4518,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
|
|||||||
*/
|
*/
|
||||||
for (i = 0 ; i < def->nnets ; i++) {
|
for (i = 0 ; i < def->nnets ; i++) {
|
||||||
virDomainNetDefPtr net = def->nets[i];
|
virDomainNetDefPtr net = def->nets[i];
|
||||||
int bootIndex = net->bootIndex;
|
int bootIndex = net->info.bootIndex;
|
||||||
if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
|
if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
|
||||||
int actualType = virDomainNetGetActualType(net);
|
int actualType = virDomainNetGetActualType(net);
|
||||||
const char *brname;
|
const char *brname;
|
||||||
@ -4576,7 +4576,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
|
|||||||
net->data.ethernet.dev = brname;
|
net->data.ethernet.dev = brname;
|
||||||
net->data.ethernet.ipaddr = ipaddr;
|
net->data.ethernet.ipaddr = ipaddr;
|
||||||
}
|
}
|
||||||
net->bootIndex = bootIndex;
|
net->info.bootIndex = bootIndex;
|
||||||
}
|
}
|
||||||
for (i = 0 ; i < def->ngraphics ; i++) {
|
for (i = 0 ; i < def->ngraphics ; i++) {
|
||||||
if (def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
|
if (def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
|
||||||
|
Loading…
Reference in New Issue
Block a user