mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-12 07:42:56 +00:00
conf: Move disk vendor and product pritability check to domain_validate
Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
e2a69d7641
commit
fc2e60fda7
@ -9433,22 +9433,10 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
|
||||
virXMLNodeNameEqual(cur, "vendor")) {
|
||||
if (!(vendor = virXMLNodeContentString(cur)))
|
||||
return NULL;
|
||||
|
||||
if (!virStringIsPrintable(vendor)) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("disk vendor is not printable string"));
|
||||
return NULL;
|
||||
}
|
||||
} else if (!product &&
|
||||
virXMLNodeNameEqual(cur, "product")) {
|
||||
if (!(product = virXMLNodeContentString(cur)))
|
||||
return NULL;
|
||||
|
||||
if (!virStringIsPrintable(product)) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("disk product is not printable string"));
|
||||
return NULL;
|
||||
}
|
||||
} else if (virXMLNodeNameEqual(cur, "boot")) {
|
||||
/* boot is parsed as part of virDomainDeviceInfoParseXML */
|
||||
} else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) &&
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "virconftypes.h"
|
||||
#include "virlog.h"
|
||||
#include "virutil.h"
|
||||
#include "virstring.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_DOMAIN
|
||||
|
||||
@ -607,18 +608,34 @@ virDomainDiskDefValidate(const virDomainDef *def,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (disk->vendor && strlen(disk->vendor) > VENDOR_LEN) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("disk vendor is more than %d characters"),
|
||||
VENDOR_LEN);
|
||||
return -1;
|
||||
if (disk->vendor) {
|
||||
if (!virStringIsPrintable(disk->vendor)) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("disk vendor is not printable string"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strlen(disk->vendor) > VENDOR_LEN) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("disk vendor is more than %d characters"),
|
||||
VENDOR_LEN);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (disk->product && strlen(disk->product) > PRODUCT_LEN) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("disk product is more than %d characters"),
|
||||
PRODUCT_LEN);
|
||||
return -1;
|
||||
if (disk->product) {
|
||||
if (!virStringIsPrintable(disk->product)) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("disk product is not printable string"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strlen(disk->product) > PRODUCT_LEN) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("disk product is more than %d characters"),
|
||||
PRODUCT_LEN);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
|
||||
|
Loading…
x
Reference in New Issue
Block a user