Re: [libvirt] Interface driver and ESX support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Okay, I finally got the patches cleaned up.

I just posted this 12 patches series to the mailing list. Apply them
all to an up to date git clone and apply the attached, updated ESX
interface driver stub patch in the end.

Patch 6 of 12 adds the binding for HostCpuIdInfo and contains the
functions to handle ArrayOf* types.

Matthias

2009/9/13 Shahar Klein <shaharklein@xxxxxxxxx>:
> I see
> You are making my (coding) life easier : )
> thanks
> ________________________________
> From: Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx>
> To: Shahar Klein <shaharklein@xxxxxxxxx>
> Cc: libvir-list@xxxxxxxxxx
> Sent: Sunday, September 13, 2009 4:39:22 PM
> Subject: Re: [libvirt] Interface driver and ESX support
>
> No, as I said before you should wait until you can use the unpublished
> binding of HostCpuIdInfo as an example. This also includes the code to
> handle ArrayOf* types. I'm currently cleaning up this patches (didn't
> have time on thursday for that) and will post them today, just wait
> for this patches, because they will help you.
>
> Matthias
>
> 2009/9/13 Shahar Klein <shaharklein@xxxxxxxxx>:
>> I've defined (among others):
>> int esxVI_PhysicalNic_CastListFromAnyType(virConnectPtr conn,
>> esxVI_AnyType
>> *anyType, esxVI_PhysicalNic **pNicList);
>> but runing it returns somthing like:
>> Expecting type 'PhysicalNic' but found 'ArrayOfPhysicalNic'
>> Does it mean I should also implement:
>> esxVI_ArrayOfPhysicalNic_CastListFromAnyType()
>> and all the funcs/type definition coming with it?
>> thanks
>> Shahar
>> ________________________________
>> From: Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx>
>> To: Shahar Klein <shaharklein@xxxxxxxxx>
>> Cc: libvir-list@xxxxxxxxxx
>> Sent: Thursday, September 10, 2009 6:24:25 PM
>> Subject: Re: [libvirt] Interface driver and ESX support
>>
>> 2009/9/10 Shahar Klein <shaharklein@xxxxxxxxx>:
>>> I'm not sure what you mean about mapping
>>> lets take the pnics as a study case for me
>>> do I need to define a structure similar to this:
>>>
>>>
>>> http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.host.PhysicalNic.html
>>> and also take care for it's allocation?
>>>
>>
>> Yes, you need to implement the mapping (a better word may be
>> 'binding') of this VI API type to a C type, that also includes to care
>> about its allocation. You'll need to implement at least this set of
>> function in esx_vi_types.[ch]:
>>
>> esxVI_PhysicalNic_Alloc()
>> esxVI_PhysicalNic_Free()
>> esxVI_PhysicalNic_CastFromAnyType()
>> esxVI_PhysicalNic_CastListFromAnyType()
>> esxVI_PhysicalNic_Deserialize()
>> esxVI_PhysicalNic_DeserializeList()
>>
>> You could use the binding for the HostCpuIdInfo type, but
>> unfortunately I haven't published the code for it yet. This code also
>> includes some essential helper functions for
>> esxVI_PhysicalNic_CastListFromAnyType().
>>
>> Beside the PhysicalNic type, you may also have to bind the types of
>> its members like PhysicalNicLinkInfo, PhysicalNicSpec and
>> HostIpConfig, if you need or care about the information provided by
>> them.
>>
>> The binding for HostCpuIdInfo is part of a larger set of patches that
>> add some new features to ESX driver, but the patches needs some
>> cleanup first. I may have some time later this evening to clean them
>> up and post them.
>>
>> PS: You should refer to version 2.5 of the VI API [1] and not 4.0,
>> because the complete VI API mapping is currently based on version 2.5.
>> At some point I'll have to properly distinguish between version 2.5
>> and 4.0, but currently I would like to stick to version 2.5 only.
>>
>> [1]
>> http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/
>>
>> Matthias
>>
>>
>
>
diff --git a/src/Makefile.am b/src/Makefile.am
index 14a3a63..5a50402 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -170,6 +170,7 @@ ONE_DRIVER_SOURCES =						\
 
 ESX_DRIVER_SOURCES =						\
 		esx/esx_driver.c esx/esx_driver.h		\
+		esx/esx_interface_driver.c esx/esx_interface_driver.h		\
 		esx/esx_util.c esx/esx_util.h			\
 		esx/esx_vi.c esx/esx_vi.h			\
 		esx/esx_vi_methods.c esx/esx_vi_methods.h	\
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index bbba445..cdecc57 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -42,6 +42,7 @@
 #include "logging.h"
 #include "uuid.h"
 #include "esx_driver.h"
+#include "esx_interface_driver.h"
 #include "esx_vi.h"
 #include "esx_vi_methods.h"
 #include "esx_util.h"
@@ -55,17 +56,6 @@
 
 static int esxDomainGetMaxVcpus(virDomainPtr domain);
 
-typedef struct _esxPrivate {
-    esxVI_Context *host;
-    esxVI_Context *vCenter;
-    virCapsPtr caps;
-    char *transport;
-    int32_t maxVcpus;
-    esxVI_Boolean supportsVMotion;
-    esxVI_Boolean supportsLongMode; /* aka x86_64 */
-    int32_t usedCpuTimeCounterId;
-} esxPrivate;
-
 
 
 static esxVI_Boolean
@@ -3276,7 +3266,13 @@ static virDriver esxDriver = {
 int
 esxRegister(void)
 {
-    virRegisterDriver(&esxDriver);
+    if (virRegisterDriver(&esxDriver) < 0) {
+        return -1;
+    }
+
+    if (esxInterfaceRegister() < 0) {
+        return -1;
+    }
 
     return 0;
 }
diff --git a/src/esx/esx_driver.h b/src/esx/esx_driver.h
index 85f4b32..4debb07 100644
--- a/src/esx/esx_driver.h
+++ b/src/esx/esx_driver.h
@@ -24,6 +24,23 @@
 #ifndef __ESX_DRIVER_H__
 #define __ESX_DRIVER_H__
 
+#include "internal.h"
+#include "capabilities.h"
+#include "esx_vi.h"
+
+typedef struct _esxPrivate {
+    esxVI_Context *host;
+    esxVI_Context *vCenter;
+    virCapsPtr caps;
+    char *transport;
+    int32_t maxVcpus;
+    esxVI_Boolean supportsVMotion;
+    esxVI_Boolean supportsLongMode; /* aka x86_64 */
+    int32_t usedCpuTimeCounterId;
+} esxPrivate;
+
+
+
 int esxRegister(void);
 
 #endif /* __ESX_DRIVER_H__ */
diff --git a/src/esx/esx_interface_driver.c b/src/esx/esx_interface_driver.c
new file mode 100644
index 0000000..3b63525
--- /dev/null
+++ b/src/esx/esx_interface_driver.c
@@ -0,0 +1,95 @@
+
+/*
+ * esx_interface_driver.h: interface driver methods for managing VMware ESX
+ *                         hosts interfaces
+ *
+ * Copyright (C) 2009 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ */
+
+#include <config.h>
+
+#include "internal.h"
+#include "virterror_internal.h"
+#include "util.h"
+#include "memory.h"
+#include "logging.h"
+#include "uuid.h"
+#include "esx_driver.h"
+#include "esx_interface_driver.h"
+#include "esx_vi.h"
+#include "esx_vi_methods.h"
+#include "esx_util.h"
+
+#define VIR_FROM_THIS VIR_FROM_ESX
+
+#define ESX_ERROR(conn, code, fmt...)                                         \
+    virReportErrorHelper(conn, VIR_FROM_ESX, code, __FILE__, __FUNCTION__,    \
+                         __LINE__, fmt)
+
+
+
+static virDrvOpenStatus
+esxInterfaceOpen(virConnectPtr conn,
+                 virConnectAuthPtr auth ATTRIBUTE_UNUSED,
+                 int flags ATTRIBUTE_UNUSED)
+{
+    if (STRNEQ(conn->driver->name, "ESX")) {
+        return VIR_DRV_OPEN_DECLINED;
+    }
+
+    conn->interfacePrivateData = conn->privateData;
+
+    return VIR_DRV_OPEN_SUCCESS;
+}
+
+
+
+static int
+esxInterfaceClose(virConnectPtr conn)
+{
+    conn->interfacePrivateData = NULL;
+
+    return 0;
+}
+
+
+
+static virInterfaceDriver esxInterfaceDriver = {
+    "ESX",                                 /* name */
+    esxInterfaceOpen,                      /* open */
+    esxInterfaceClose,                     /* close */
+    NULL,                                  /* numOfInterfaces */
+    NULL,                                  /* listInterfaces */
+    NULL,                                  /* numOfDefinedInterfaces */
+    NULL,                                  /* listDefinedInterfaces */
+    NULL,                                  /* interfaceLookupByName */
+    NULL,                                  /* interfaceLookupByMACString */
+    NULL,                                  /* interfaceGetXMLDesc */
+    NULL,                                  /* interfaceDefineXML */
+    NULL,                                  /* interfaceUndefine */
+    NULL,                                  /* interfaceCreate */
+    NULL,                                  /* interfaceDestroy */
+};
+
+
+
+int
+esxInterfaceRegister(void)
+{
+    return virRegisterInterfaceDriver(&esxInterfaceDriver);
+}
diff --git a/src/esx/esx_interface_driver.h b/src/esx/esx_interface_driver.h
new file mode 100644
index 0000000..b9eec24
--- /dev/null
+++ b/src/esx/esx_interface_driver.h
@@ -0,0 +1,29 @@
+
+/*
+ * esx_interface_driver.h: interface driver methods for managing VMware ESX
+ *                         hosts interfaces
+ *
+ * Copyright (C) 2009 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ */
+
+#ifndef __ESX_INTERFACE_DRIVER_H__
+#define __ESX_INTERFACE_DRIVER_H__
+
+int esxInterfaceRegister(void);
+
+#endif /* __ESX_INTERFACE_DRIVER_H__ */
--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]