mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
conf: Parse and for the tray attribute
The "tray" is only allowed for removable disks, i.e. CDROM and Floppy disks.
This commit is contained in:
parent
ab49b392cc
commit
b22eaa7538
@ -630,6 +630,10 @@ VIR_ENUM_IMPL(virDomainCpuPlacementMode, VIR_DOMAIN_CPU_PLACEMENT_MODE_LAST,
|
||||
"static",
|
||||
"auto");
|
||||
|
||||
VIR_ENUM_IMPL(virDomainDiskTray, VIR_DOMAIN_DISK_TRAY_LAST,
|
||||
"closed",
|
||||
"open");
|
||||
|
||||
#define virDomainReportError(code, ...) \
|
||||
virReportErrorHelper(VIR_FROM_DOMAIN, code, __FILE__, \
|
||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
@ -3313,6 +3317,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
|
||||
char *authUsage = NULL;
|
||||
char *authUUID = NULL;
|
||||
char *usageType = NULL;
|
||||
char *tray = NULL;
|
||||
|
||||
if (VIR_ALLOC(def) < 0) {
|
||||
virReportOOMError();
|
||||
@ -3421,6 +3426,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
|
||||
(xmlStrEqual(cur->name, BAD_CAST "target"))) {
|
||||
target = virXMLPropString(cur, "dev");
|
||||
bus = virXMLPropString(cur, "bus");
|
||||
tray = virXMLPropString(cur, "tray");
|
||||
|
||||
/* HACK: Work around for compat with Xen
|
||||
* driver in previous libvirt releases */
|
||||
@ -3690,6 +3696,25 @@ virDomainDiskDefParseXML(virCapsPtr caps,
|
||||
}
|
||||
}
|
||||
|
||||
if (tray) {
|
||||
if ((def->tray_status = virDomainDiskTrayTypeFromString(tray)) < 0) {
|
||||
virDomainReportError(VIR_ERR_XML_ERROR,
|
||||
_("unknown disk tray status '%s'"), tray);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
|
||||
def->device != VIR_DOMAIN_DISK_DEVICE_CDROM) {
|
||||
virDomainReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("tray is only valid for cdrom and floppy"));
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
if (def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY ||
|
||||
def->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
|
||||
def->tray_status = VIR_DOMAIN_DISK_TRAY_CLOSED;
|
||||
}
|
||||
|
||||
if (def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
|
||||
def->bus != VIR_DOMAIN_DISK_BUS_FDC) {
|
||||
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
@ -10721,8 +10746,15 @@ virDomainDiskDefFormat(virBufferPtr buf,
|
||||
}
|
||||
}
|
||||
|
||||
virBufferAsprintf(buf, " <target dev='%s' bus='%s'/>\n",
|
||||
virBufferAsprintf(buf, " <target dev='%s' bus='%s'",
|
||||
def->dst, bus);
|
||||
if ((def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY ||
|
||||
def->device == VIR_DOMAIN_DISK_DEVICE_CDROM) &&
|
||||
(def->tray_status != VIR_DOMAIN_DISK_TRAY_CLOSED))
|
||||
virBufferAsprintf(buf, " tray='%s'/>\n",
|
||||
virDomainDiskTrayTypeToString(def->tray_status));
|
||||
else
|
||||
virBufferAddLit(buf, "/>\n");
|
||||
|
||||
/*disk I/O throttling*/
|
||||
if (def->blkdeviotune.total_bytes_sec ||
|
||||
|
@ -451,6 +451,13 @@ enum virDomainDiskProtocol {
|
||||
VIR_DOMAIN_DISK_PROTOCOL_LAST
|
||||
};
|
||||
|
||||
enum virDomainDiskTray {
|
||||
VIR_DOMAIN_DISK_TRAY_CLOSED,
|
||||
VIR_DOMAIN_DISK_TRAY_OPEN,
|
||||
|
||||
VIR_DOMAIN_DISK_TRAY_LAST
|
||||
};
|
||||
|
||||
typedef struct _virDomainDiskHostDef virDomainDiskHostDef;
|
||||
typedef virDomainDiskHostDef *virDomainDiskHostDefPtr;
|
||||
struct _virDomainDiskHostDef {
|
||||
@ -541,6 +548,7 @@ struct _virDomainDiskDef {
|
||||
char *src;
|
||||
virSecurityDeviceLabelDefPtr seclabel;
|
||||
char *dst;
|
||||
int tray_status;
|
||||
int protocol;
|
||||
int nhosts;
|
||||
virDomainDiskHostDefPtr hosts;
|
||||
@ -2103,6 +2111,7 @@ VIR_ENUM_DECL(virDomainDiskProtocol)
|
||||
VIR_ENUM_DECL(virDomainDiskIo)
|
||||
VIR_ENUM_DECL(virDomainDiskSecretType)
|
||||
VIR_ENUM_DECL(virDomainDiskSnapshot)
|
||||
VIR_ENUM_DECL(virDomainDiskTray)
|
||||
VIR_ENUM_DECL(virDomainIoEventFd)
|
||||
VIR_ENUM_DECL(virDomainVirtioEventIdx)
|
||||
VIR_ENUM_DECL(virDomainDiskCopyOnRead)
|
||||
|
Loading…
Reference in New Issue
Block a user