|
|
147b37 |
From 5ca21a5c83e1c712d4d90f1981a23117ec8010f9 Mon Sep 17 00:00:00 2001
|
|
|
147b37 |
Message-Id: <5ca21a5c83e1c712d4d90f1981a23117ec8010f9@dist-git>
|
|
|
147b37 |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
147b37 |
Date: Thu, 12 Apr 2018 17:26:18 +0200
|
|
|
147b37 |
Subject: [PATCH] vmx: check for present/enabled devices earlier
|
|
|
147b37 |
MIME-Version: 1.0
|
|
|
147b37 |
Content-Type: text/plain; charset=UTF-8
|
|
|
147b37 |
Content-Transfer-Encoding: 8bit
|
|
|
147b37 |
|
|
|
147b37 |
When parsing filesystems, network interfaces, serial ports, and
|
|
|
147b37 |
parallel ports, check earlier whether they are present/enabled, delaying
|
|
|
147b37 |
the allocation of the objects.
|
|
|
147b37 |
|
|
|
147b37 |
This is mostly a small optimization, with no behaviour change.
|
|
|
147b37 |
|
|
|
147b37 |
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
|
|
|
147b37 |
(cherry picked from commit 5d5430e1fc6f853f79da39fbef08e97bebffc8eb)
|
|
|
147b37 |
|
|
|
147b37 |
https: //bugzilla.redhat.com/show_bug.cgi?id=1566524
|
|
|
147b37 |
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
|
|
|
147b37 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
147b37 |
---
|
|
|
147b37 |
src/vmx/vmx.c | 92 +++++++++++++++++----------------------------------
|
|
|
147b37 |
1 file changed, 30 insertions(+), 62 deletions(-)
|
|
|
147b37 |
|
|
|
147b37 |
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
|
|
|
147b37 |
index 622f22f037..85bf195cd7 100644
|
|
|
147b37 |
--- a/src/vmx/vmx.c
|
|
|
147b37 |
+++ b/src/vmx/vmx.c
|
|
|
147b37 |
@@ -2439,11 +2439,6 @@ int virVMXParseFileSystem(virConfPtr conf, int number, virDomainFSDefPtr *def)
|
|
|
147b37 |
return -1;
|
|
|
147b37 |
}
|
|
|
147b37 |
|
|
|
147b37 |
- if (!(*def = virDomainFSDefNew()))
|
|
|
147b37 |
- return -1;
|
|
|
147b37 |
-
|
|
|
147b37 |
- (*def)->type = VIR_DOMAIN_FS_TYPE_MOUNT;
|
|
|
147b37 |
-
|
|
|
147b37 |
snprintf(prefix, sizeof(prefix), "sharedFolder%d", number);
|
|
|
147b37 |
|
|
|
147b37 |
VMX_BUILD_NAME(present);
|
|
|
147b37 |
@@ -2454,14 +2449,19 @@ int virVMXParseFileSystem(virConfPtr conf, int number, virDomainFSDefPtr *def)
|
|
|
147b37 |
|
|
|
147b37 |
/* vmx:present */
|
|
|
147b37 |
if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0)
|
|
|
147b37 |
- goto cleanup;
|
|
|
147b37 |
+ return -1;
|
|
|
147b37 |
|
|
|
147b37 |
/* vmx:enabled */
|
|
|
147b37 |
if (virVMXGetConfigBoolean(conf, enabled_name, &enabled, false, true) < 0)
|
|
|
147b37 |
- goto cleanup;
|
|
|
147b37 |
+ return -1;
|
|
|
147b37 |
|
|
|
147b37 |
if (!(present && enabled))
|
|
|
147b37 |
- goto ignore;
|
|
|
147b37 |
+ return 0;
|
|
|
147b37 |
+
|
|
|
147b37 |
+ if (!(*def = virDomainFSDefNew()))
|
|
|
147b37 |
+ return -1;
|
|
|
147b37 |
+
|
|
|
147b37 |
+ (*def)->type = VIR_DOMAIN_FS_TYPE_MOUNT;
|
|
|
147b37 |
|
|
|
147b37 |
/* vmx:hostPath */
|
|
|
147b37 |
if (virVMXGetConfigString(conf, hostPath_name, &hostPath, false) < 0)
|
|
|
147b37 |
@@ -2497,14 +2497,6 @@ int virVMXParseFileSystem(virConfPtr conf, int number, virDomainFSDefPtr *def)
|
|
|
147b37 |
VIR_FREE(guestName);
|
|
|
147b37 |
|
|
|
147b37 |
return result;
|
|
|
147b37 |
-
|
|
|
147b37 |
- ignore:
|
|
|
147b37 |
- virDomainFSDefFree(*def);
|
|
|
147b37 |
- *def = NULL;
|
|
|
147b37 |
-
|
|
|
147b37 |
- result = 0;
|
|
|
147b37 |
-
|
|
|
147b37 |
- goto cleanup;
|
|
|
147b37 |
}
|
|
|
147b37 |
|
|
|
147b37 |
|
|
|
147b37 |
@@ -2557,9 +2549,6 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
|
|
|
147b37 |
return -1;
|
|
|
147b37 |
}
|
|
|
147b37 |
|
|
|
147b37 |
- if (VIR_ALLOC(*def) < 0)
|
|
|
147b37 |
- return -1;
|
|
|
147b37 |
-
|
|
|
147b37 |
snprintf(prefix, sizeof(prefix), "ethernet%d", controller);
|
|
|
147b37 |
|
|
|
147b37 |
VMX_BUILD_NAME(present);
|
|
|
147b37 |
@@ -2575,17 +2564,20 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
|
|
|
147b37 |
|
|
|
147b37 |
/* vmx:present */
|
|
|
147b37 |
if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0)
|
|
|
147b37 |
- goto cleanup;
|
|
|
147b37 |
+ return -1;
|
|
|
147b37 |
|
|
|
147b37 |
/* vmx:startConnected */
|
|
|
147b37 |
if (virVMXGetConfigBoolean(conf, startConnected_name, &startConnected,
|
|
|
147b37 |
true, true) < 0) {
|
|
|
147b37 |
- goto cleanup;
|
|
|
147b37 |
+ return -1;
|
|
|
147b37 |
}
|
|
|
147b37 |
|
|
|
147b37 |
/* FIXME: Need to distiguish between active and inactive domains here */
|
|
|
147b37 |
if (! present/* && ! startConnected*/)
|
|
|
147b37 |
- goto ignore;
|
|
|
147b37 |
+ return 0;
|
|
|
147b37 |
+
|
|
|
147b37 |
+ if (VIR_ALLOC(*def) < 0)
|
|
|
147b37 |
+ return -1;
|
|
|
147b37 |
|
|
|
147b37 |
/* vmx:connectionType -> def:type */
|
|
|
147b37 |
if (virVMXGetConfigString(conf, connectionType_name, &connectionType,
|
|
|
147b37 |
@@ -2726,14 +2718,6 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
|
|
|
147b37 |
VIR_FREE(vnet);
|
|
|
147b37 |
|
|
|
147b37 |
return result;
|
|
|
147b37 |
-
|
|
|
147b37 |
- ignore:
|
|
|
147b37 |
- virDomainNetDefFree(*def);
|
|
|
147b37 |
- *def = NULL;
|
|
|
147b37 |
-
|
|
|
147b37 |
- result = 0;
|
|
|
147b37 |
-
|
|
|
147b37 |
- goto cleanup;
|
|
|
147b37 |
}
|
|
|
147b37 |
|
|
|
147b37 |
|
|
|
147b37 |
@@ -2773,11 +2757,6 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
|
|
|
147b37 |
return -1;
|
|
|
147b37 |
}
|
|
|
147b37 |
|
|
|
147b37 |
- if (!(*def = virDomainChrDefNew(NULL)))
|
|
|
147b37 |
- return -1;
|
|
|
147b37 |
-
|
|
|
147b37 |
- (*def)->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
|
|
|
147b37 |
-
|
|
|
147b37 |
snprintf(prefix, sizeof(prefix), "serial%d", port);
|
|
|
147b37 |
|
|
|
147b37 |
VMX_BUILD_NAME(present);
|
|
|
147b37 |
@@ -2788,17 +2767,22 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
|
|
|
147b37 |
|
|
|
147b37 |
/* vmx:present */
|
|
|
147b37 |
if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0)
|
|
|
147b37 |
- goto cleanup;
|
|
|
147b37 |
+ return -1;
|
|
|
147b37 |
|
|
|
147b37 |
/* vmx:startConnected */
|
|
|
147b37 |
if (virVMXGetConfigBoolean(conf, startConnected_name, &startConnected,
|
|
|
147b37 |
true, true) < 0) {
|
|
|
147b37 |
- goto cleanup;
|
|
|
147b37 |
+ return -1;
|
|
|
147b37 |
}
|
|
|
147b37 |
|
|
|
147b37 |
/* FIXME: Need to distiguish between active and inactive domains here */
|
|
|
147b37 |
if (! present/* && ! startConnected*/)
|
|
|
147b37 |
- goto ignore;
|
|
|
147b37 |
+ return 0;
|
|
|
147b37 |
+
|
|
|
147b37 |
+ if (!(*def = virDomainChrDefNew(NULL)))
|
|
|
147b37 |
+ return -1;
|
|
|
147b37 |
+
|
|
|
147b37 |
+ (*def)->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
|
|
|
147b37 |
|
|
|
147b37 |
/* vmx:fileType -> def:type */
|
|
|
147b37 |
if (virVMXGetConfigString(conf, fileType_name, &fileType, true) < 0)
|
|
|
147b37 |
@@ -2919,14 +2903,6 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
|
|
|
147b37 |
virURIFree(parsedUri);
|
|
|
147b37 |
|
|
|
147b37 |
return result;
|
|
|
147b37 |
-
|
|
|
147b37 |
- ignore:
|
|
|
147b37 |
- virDomainChrDefFree(*def);
|
|
|
147b37 |
- *def = NULL;
|
|
|
147b37 |
-
|
|
|
147b37 |
- result = 0;
|
|
|
147b37 |
-
|
|
|
147b37 |
- goto cleanup;
|
|
|
147b37 |
}
|
|
|
147b37 |
|
|
|
147b37 |
|
|
|
147b37 |
@@ -2961,11 +2937,6 @@ virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port,
|
|
|
147b37 |
return -1;
|
|
|
147b37 |
}
|
|
|
147b37 |
|
|
|
147b37 |
- if (!(*def = virDomainChrDefNew(NULL)))
|
|
|
147b37 |
- return -1;
|
|
|
147b37 |
-
|
|
|
147b37 |
- (*def)->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
|
|
|
147b37 |
-
|
|
|
147b37 |
snprintf(prefix, sizeof(prefix), "parallel%d", port);
|
|
|
147b37 |
|
|
|
147b37 |
VMX_BUILD_NAME(present);
|
|
|
147b37 |
@@ -2975,17 +2946,22 @@ virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port,
|
|
|
147b37 |
|
|
|
147b37 |
/* vmx:present */
|
|
|
147b37 |
if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0)
|
|
|
147b37 |
- goto cleanup;
|
|
|
147b37 |
+ return -1;
|
|
|
147b37 |
|
|
|
147b37 |
/* vmx:startConnected */
|
|
|
147b37 |
if (virVMXGetConfigBoolean(conf, startConnected_name, &startConnected,
|
|
|
147b37 |
true, true) < 0) {
|
|
|
147b37 |
- goto cleanup;
|
|
|
147b37 |
+ return -1;
|
|
|
147b37 |
}
|
|
|
147b37 |
|
|
|
147b37 |
/* FIXME: Need to distiguish between active and inactive domains here */
|
|
|
147b37 |
if (! present/* && ! startConnected*/)
|
|
|
147b37 |
- goto ignore;
|
|
|
147b37 |
+ return 0;
|
|
|
147b37 |
+
|
|
|
147b37 |
+ if (!(*def = virDomainChrDefNew(NULL)))
|
|
|
147b37 |
+ return -1;
|
|
|
147b37 |
+
|
|
|
147b37 |
+ (*def)->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
|
|
|
147b37 |
|
|
|
147b37 |
/* vmx:fileType -> def:type */
|
|
|
147b37 |
if (virVMXGetConfigString(conf, fileType_name, &fileType, false) < 0)
|
|
|
147b37 |
@@ -3029,14 +3005,6 @@ virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port,
|
|
|
147b37 |
VIR_FREE(fileName);
|
|
|
147b37 |
|
|
|
147b37 |
return result;
|
|
|
147b37 |
-
|
|
|
147b37 |
- ignore:
|
|
|
147b37 |
- virDomainChrDefFree(*def);
|
|
|
147b37 |
- *def = NULL;
|
|
|
147b37 |
-
|
|
|
147b37 |
- result = 0;
|
|
|
147b37 |
-
|
|
|
147b37 |
- goto cleanup;
|
|
|
147b37 |
}
|
|
|
147b37 |
|
|
|
147b37 |
|
|
|
147b37 |
--
|
|
|
147b37 |
2.17.0
|
|
|
147b37 |
|