提交 535aed56 编写于 作者: O Osier Yang

conf: Parse and format the new XML

Like "rawio", "sgio" is only allowed for block disk of device
type "lun".

It doesn't default disk->sgio to "filtered" when parsing, as
it won't be able to distinguish explicitly requested "filtered"
and a default "filtered" in driver then. We have to error out for
explicit request when the kernel doesn't support the new sysfs
knob "unpriv_sgio", however, for defaulted "filtered", we can
just ignore it if the kernel doesn't support "unpriv_sgio".
上级 b9c57e7b
......@@ -241,6 +241,12 @@ VIR_ENUM_IMPL(virDomainDiskIo, VIR_DOMAIN_DISK_IO_LAST,
"default",
"native",
"threads")
VIR_ENUM_IMPL(virDomainDiskSGIO, VIR_DOMAIN_DISK_SGIO_LAST,
"default",
"filtered",
"unfiltered")
VIR_ENUM_IMPL(virDomainIoEventFd, VIR_DOMAIN_IO_EVENT_FD_LAST,
"default",
"on",
......@@ -3593,6 +3599,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
char *device = NULL;
char *snapshot = NULL;
char *rawio = NULL;
char *sgio = NULL;
char *driverName = NULL;
char *driverType = NULL;
char *source = NULL;
......@@ -3657,6 +3664,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
snapshot = virXMLPropString(node, "snapshot");
rawio = virXMLPropString(node, "rawio");
sgio = virXMLPropString(node, "sgio");
cur = node->children;
while (cur != NULL) {
......@@ -4107,22 +4115,32 @@ virDomainDiskDefParseXML(virCapsPtr caps,
def->snapshot = VIR_DOMAIN_SNAPSHOT_LOCATION_NONE;
}
if ((rawio || sgio) &&
(def->device != VIR_DOMAIN_DISK_DEVICE_LUN)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("rawio or sgio can be used only with "
"device='lun'"));
goto error;
}
if (rawio) {
def->rawio_specified = true;
if (def->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
if (STREQ(rawio, "yes")) {
def->rawio = 1;
} else if (STREQ(rawio, "no")) {
def->rawio = 0;
} else {
virReportError(VIR_ERR_XML_ERROR,
_("unknown disk rawio setting '%s'"),
rawio);
goto error;
}
if (STREQ(rawio, "yes")) {
def->rawio = 1;
} else if (STREQ(rawio, "no")) {
def->rawio = 0;
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("rawio can be used only with device='lun'"));
virReportError(VIR_ERR_XML_ERROR,
_("unknown disk rawio setting '%s'"),
rawio);
goto error;
}
}
if (sgio) {
if ((def->sgio = virDomainDiskSGIOTypeFromString(sgio)) <= 0) {
virReportError(VIR_ERR_XML_ERROR,
_("unknown disk sgio mode '%s'"), sgio);
goto error;
}
}
......@@ -4365,6 +4383,7 @@ cleanup:
VIR_FREE(type);
VIR_FREE(snapshot);
VIR_FREE(rawio);
VIR_FREE(sgio);
VIR_FREE(target);
VIR_FREE(source);
VIR_FREE(tray);
......@@ -12132,6 +12151,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
const char *event_idx = virDomainVirtioEventIdxTypeToString(def->event_idx);
const char *copy_on_read = virDomainVirtioEventIdxTypeToString(def->copy_on_read);
const char *startupPolicy = virDomainStartupPolicyTypeToString(def->startupPolicy);
const char *sgio = virDomainDiskSGIOTypeToString(def->sgio);
int n;
char uuidstr[VIR_UUID_STRING_BUFLEN];
......@@ -12161,6 +12181,11 @@ virDomainDiskDefFormat(virBufferPtr buf,
_("unexpected disk io mode %d"), def->iomode);
return -1;
}
if (!sgio) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected disk sgio mode '%d'"), def->sgio);
return -1;
}
virBufferAsprintf(buf,
" <disk type='%s' device='%s'",
......@@ -12172,6 +12197,10 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferAddLit(buf, " rawio='no'");
}
}
if (def->sgio)
virBufferAsprintf(buf, " sgio='%s'", sgio);
if (def->snapshot &&
!(def->snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_NONE && def->readonly))
virBufferAsprintf(buf, " snapshot='%s'",
......
......@@ -566,6 +566,14 @@ enum virDomainDiskSecretType {
VIR_DOMAIN_DISK_SECRET_TYPE_LAST
};
enum virDomainDiskSGIO {
VIR_DOMAIN_DISK_SGIO_DEFAULT = 0,
VIR_DOMAIN_DISK_SGIO_FILTERED,
VIR_DOMAIN_DISK_SGIO_UNFILTERED,
VIR_DOMAIN_DISK_SGIO_LAST
};
typedef struct _virDomainBlockIoTuneInfo virDomainBlockIoTuneInfo;
struct _virDomainBlockIoTuneInfo {
unsigned long long total_bytes_sec;
......@@ -638,6 +646,7 @@ struct _virDomainDiskDef {
virStorageEncryptionPtr encryption;
bool rawio_specified;
int rawio; /* no = 0, yes = 1 */
int sgio; /* enum virDomainDiskSGIO */
size_t nseclabels;
virSecurityDeviceLabelDefPtr *seclabels;
......@@ -2232,6 +2241,7 @@ VIR_ENUM_DECL(virDomainDiskProtocol)
VIR_ENUM_DECL(virDomainDiskProtocolTransport)
VIR_ENUM_DECL(virDomainDiskIo)
VIR_ENUM_DECL(virDomainDiskSecretType)
VIR_ENUM_DECL(virDomainDiskSGIO)
VIR_ENUM_DECL(virDomainDiskTray)
VIR_ENUM_DECL(virDomainIoEventFd)
VIR_ENUM_DECL(virDomainVirtioEventIdx)
......
<domain type='qemu'>
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219136</memory>
<currentMemory unit='KiB'>219136</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu</emulator>
<disk type='block' device='lun' rawio='no' sgio='unfiltered'>
<source dev='/dev/HostVG/QEMUGuest1'/>
<target dev='hda' bus='scsi'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<disk type='block' device='lun' sgio='filtered'>
<source dev='/dev/HostVG/QEMUGuest2'/>
<target dev='hda' bus='scsi'/>
<address type='drive' controller='0' bus='0' target='1' unit='1'/>
</disk>
<controller type='scsi' index='0' model='virtio-scsi'/>
<controller type='scsi' index='1' model='lsilogic'/>
<controller type='usb' index='0'/>
<memballoon model='virtio'/>
</devices>
</domain>
......@@ -238,6 +238,7 @@ mymain(void)
DO_TEST("seclabel-static");
DO_TEST("seclabel-none");
DO_TEST("numad-static-vcpu-no-numatune");
DO_TEST("disk-scsi-lun-passthrough-sgio");
DO_TEST("disk-scsi-disk-vpd");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册