conf: snapshot: Remove VIR_DOMAIN_SNAPSHOT_PARSE_DISKS flag

All callers except the one in the 'esx' driver pass the flag. The 'esx'
driver has a check that 'def->ndisks' is zero after parsing the
definition. This means that we can simply always parse the disks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-03-08 18:20:46 +01:00
parent fc81be4bfa
commit c250ab90ac
8 changed files with 16 additions and 27 deletions

View File

@ -359,21 +359,15 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
if ((n = virXPathNodeSet("./disks/*", ctxt, &nodes)) < 0)
goto cleanup;
if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_DISKS) {
if (n)
def->disks = g_new0(virDomainSnapshotDiskDef, n);
def->ndisks = n;
for (i = 0; i < def->ndisks; i++) {
if (virDomainSnapshotDiskDefParseXML(nodes[i], ctxt, &def->disks[i],
flags, xmlopt) < 0)
goto cleanup;
}
VIR_FREE(nodes);
} else if (n) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("unable to handle disk requests in snapshot"));
goto cleanup;
if (n)
def->disks = g_new0(virDomainSnapshotDiskDef, n);
def->ndisks = n;
for (i = 0; i < def->ndisks; i++) {
if (virDomainSnapshotDiskDefParseXML(nodes[i], ctxt, &def->disks[i],
flags, xmlopt) < 0)
goto cleanup;
}
VIR_FREE(nodes);
if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL) {
if (!current) {

View File

@ -84,10 +84,9 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainSnapshotDef, virObjectUnref);
typedef enum {
VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE = 1 << 0,
VIR_DOMAIN_SNAPSHOT_PARSE_DISKS = 1 << 1,
VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL = 1 << 2,
VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE = 1 << 3,
VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE = 1 << 4,
VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL = 1 << 1,
VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE = 1 << 2,
VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE = 1 << 3,
} virDomainSnapshotParseFlags;
typedef enum {

View File

@ -347,7 +347,6 @@ qemuDomainSnapshotLoad(virDomainObj *vm,
virDomainMomentObj *current = NULL;
bool cur;
unsigned int flags = (VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE |
VIR_DOMAIN_SNAPSHOT_PARSE_DISKS |
VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL);
int ret = -1;
int direrr;

View File

@ -1530,7 +1530,7 @@ qemuSnapshotCreateXMLParse(virDomainObj *vm,
unsigned int flags)
{
qemuDomainObjPrivate *priv = vm->privateData;
unsigned int parse_flags = VIR_DOMAIN_SNAPSHOT_PARSE_DISKS;
unsigned int parse_flags = 0;
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE)
parse_flags |= VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE;

View File

@ -978,7 +978,6 @@ testParseDomainSnapshots(testDriver *privconn,
privconn->xmlopt,
NULL,
&cur,
VIR_DOMAIN_SNAPSHOT_PARSE_DISKS |
VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL |
VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE);
if (!def)
@ -8777,7 +8776,7 @@ testDomainSnapshotCreateXML(virDomainPtr domain,
virObjectEvent *event = NULL;
bool update_current = true;
bool redefine = flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE;
unsigned int parse_flags = VIR_DOMAIN_SNAPSHOT_PARSE_DISKS;
unsigned int parse_flags = 0;
g_autoptr(virDomainSnapshotDef) def = NULL;
/*

View File

@ -5364,8 +5364,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
nsresult rc;
resultCodeUnion result;
virDomainSnapshotPtr ret = NULL;
unsigned int parse_flags = (VIR_DOMAIN_SNAPSHOT_PARSE_DISKS |
VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE);
unsigned int parse_flags = VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE;
g_autoptr(virDomainSnapshotDef) def = NULL;
if (!data->vboxObj)
@ -6783,7 +6782,6 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
}
def = virDomainSnapshotDefParseString(defXml,
data->xmlopt, NULL, NULL,
VIR_DOMAIN_SNAPSHOT_PARSE_DISKS |
VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE);
if (!def) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",

View File

@ -2580,7 +2580,7 @@ vzDomainSnapshotCreateXML(virDomainPtr domain,
virDomainObj *dom;
struct _vzConn *privconn = domain->conn->privateData;
struct _vzDriver *driver = privconn->driver;
unsigned int parse_flags = VIR_DOMAIN_SNAPSHOT_PARSE_DISKS;
unsigned int parse_flags = 0;
virDomainSnapshotObjList *snapshots = NULL;
virDomainMomentObj *current;
bool job = false;

View File

@ -34,7 +34,7 @@ testCompareXMLToXMLFiles(const char *inxml,
g_autofree char *inXmlData = NULL;
g_autofree char *outXmlData = NULL;
g_autofree char *actual = NULL;
unsigned int parseflags = VIR_DOMAIN_SNAPSHOT_PARSE_DISKS;
unsigned int parseflags = 0;
unsigned int formatflags = VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE;
bool cur = false;
g_autoptr(virDomainSnapshotDef) def = NULL;