[PATCH 2/9] esx: Expose esxParseVMXFileName() for tests

Michal Privoznik via Devel posted 9 patches 1 day, 1 hour ago
[PATCH 2/9] esx: Expose esxParseVMXFileName() for tests
Posted by Michal Privoznik via Devel 1 day, 1 hour ago
From: Michal Privoznik <mprivozn@redhat.com>

So far, our vmx2xmltest uses a custom .parseFileName callback.
And it kind of makes sense because the one that's used in
production (esxParseVMXFileName()) does some HTTP requests which
we don't want to do in our test suite. But this creates other
sorts of problems and the idea is to have the test ditch custom
parse callback and stick with the production one. But for now,
just expose it. With it, the esxVMX_Data struct is exposed too as
it is passed into the function (via 'opaque' argument).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/esx/esx_driver.c     | 13 +++----------
 src/esx/esx_driverpriv.h | 27 +++++++++++++++++++++++++++
 src/libvirt_esx.syms     |  4 ++++
 3 files changed, 34 insertions(+), 10 deletions(-)
 create mode 100644 src/esx/esx_driverpriv.h

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 34c0e28d31..6452a33b7c 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -33,11 +33,12 @@
 #include "vmx.h"
 #include "virtypedparam.h"
 #include "esx_driver.h"
+#define LIBVIRT_ESX_DRIVERPRIV_H_ALLOW
+#include "esx_driverpriv.h"
 #include "esx_interface_driver.h"
 #include "esx_network_driver.h"
 #include "esx_storage_driver.h"
 #include "esx_private.h"
-#include "esx_vi.h"
 #include "esx_vi_methods.h"
 #include "esx_util.h"
 #include "esx_stream.h"
@@ -50,14 +51,6 @@ VIR_LOG_INIT("esx.esx_driver");
 
 static int esxDomainGetMaxVcpus(virDomainPtr domain);
 
-typedef struct _esxVMX_Data esxVMX_Data;
-
-struct _esxVMX_Data {
-    esxVI_Context *ctx;
-    char *datastorePathWithoutFileName;
-};
-
-
 
 static void
 esxFreePrivate(esxPrivate **priv)
@@ -124,7 +117,7 @@ esxFreePrivate(esxPrivate **priv)
  * exception and need special handling. Parse the datastore name and use it
  * to lookup the datastore by name to verify that it exists.
  */
-static int
+int
 esxParseVMXFileName(const char *fileName,
                     void *opaque,
                     char **out,
diff --git a/src/esx/esx_driverpriv.h b/src/esx/esx_driverpriv.h
new file mode 100644
index 0000000000..c947866d4e
--- /dev/null
+++ b/src/esx/esx_driverpriv.h
@@ -0,0 +1,27 @@
+/*
+ * esx_driverpriv.h: private declarations for ESX driver
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef LIBVIRT_ESX_DRIVERPRIV_H_ALLOW
+# error "esx_driverpriv.h may only be included by esx_driver.c or test suites"
+#endif /* LIBVIRT_ESX_DRIVERPRIV_H_ALLOW */
+
+#pragma once
+
+#include "esx_vi.h"
+
+typedef struct _esxVMX_Data esxVMX_Data;
+
+struct _esxVMX_Data {
+    esxVI_Context *ctx;
+    char *datastorePathWithoutFileName;
+};
+
+
+int
+esxParseVMXFileName(const char *fileName,
+                    void *opaque,
+                    char **out,
+                    bool allow_missing);
diff --git a/src/libvirt_esx.syms b/src/libvirt_esx.syms
index 023fecbe94..6a61b7019c 100644
--- a/src/libvirt_esx.syms
+++ b/src/libvirt_esx.syms
@@ -2,6 +2,10 @@
 # These symbols are dependent upon --with-esx via WITH_ESX
 #
 
+# esx/esx_driverpriv.h
+esxParseVMXFileName;
+
+
 # esx/esx_util.h
 esxUtil_EscapeDatastoreItem;
 esxUtil_ParseDatastorePath;
-- 
2.51.0