Hi All,

I have attached a patch which when applied on the HEAD as of today would
allow virtualbox support in libvirt.

The patch works very well with the VirtualBox OSE version and the 2.2 Beta 
release.

[PATCH 1/2] contains diff of files already in libvirt.
[PATCH 2/2] contains new files needed for VirtualBox support.

Regards,
-pritesh
diff --git a/configure.in b/configure.in
index 413d27c..b02595b 100644
--- a/configure.in
+++ b/configure.in
@@ -182,6 +182,8 @@ AC_ARG_WITH([uml],
 [  --with-uml              add UML support (on)],[],[with_uml=yes])
 AC_ARG_WITH([openvz],
 [  --with-openvz           add OpenVZ support (on)],[],[with_openvz=yes])
+AC_ARG_WITH([vbox],
+[  --with-vbox             add VirtualBox support (off)],[],[with_vbox=no])
 AC_ARG_WITH([lxc],
 [  --with-lxc              add Linux Container support (on)],[],[with_lxc=yes])
 AC_ARG_WITH([test],
@@ -277,6 +279,11 @@ if test "$with_openvz" = "yes"; then
 fi
 AM_CONDITIONAL([WITH_OPENVZ], [test "$with_openvz" = "yes"])
 
+if test "x$with_vbox" = "xyes"; then
+    AC_DEFINE_UNQUOTED([WITH_VBOX], 1, [whether VirtualBox driver is enabled])
+fi
+AM_CONDITIONAL([WITH_VBOX], [test "$with_vbox" = "yes"])
+
 if test "$with_libvirtd" = "no" ; then
   with_lxc=no
 fi
@@ -1344,6 +1351,7 @@ AC_MSG_NOTICE([   Proxy: $with_xen_proxy])
 AC_MSG_NOTICE([    QEMU: $with_qemu])
 AC_MSG_NOTICE([     UML: $with_uml])
 AC_MSG_NOTICE([  OpenVZ: $with_openvz])
+AC_MSG_NOTICE([    VBox: $with_vbox])
 AC_MSG_NOTICE([     LXC: $with_lxc])
 AC_MSG_NOTICE([    Test: $with_test])
 AC_MSG_NOTICE([  Remote: $with_remote])
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index 2c3777d..faf3f61 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -62,6 +62,7 @@ typedef enum {
     VIR_FROM_NODEDEV, /* Error from node device monitor */
     VIR_FROM_XEN_INOTIFY, /* Error from xen inotify layer */
     VIR_FROM_SECURITY,  /* Error from security framework */
+    VIR_FROM_VBOX,    /* Error from VirtualBox driver */
 } virErrorDomain;
 
 
diff --git a/src/Makefile.am b/src/Makefile.am
index d5aac11..f04e38d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -129,6 +129,11 @@ OPENVZ_DRIVER_SOURCES =						\
 		openvz_conf.c openvz_conf.h			\
 		openvz_driver.c openvz_driver.h
 
+VBOX_DRIVER_SOURCES =                               \
+        vbox/VBoxXPCOMCGlue.c vbox/VBoxXPCOMCGlue.h \
+        vbox/vbox_driver.c vbox/vbox_driver.h       \
+        vbox/vbox_V2_2.c
+
 QEMU_DRIVER_SOURCES =						\
 		qemu_conf.c qemu_conf.h				\
 		qemu_driver.c qemu_driver.h
@@ -268,6 +273,19 @@ endif
 libvirt_driver_openvz_la_SOURCES = $(OPENVZ_DRIVER_SOURCES)
 endif
 
+if WITH_VBOX
+if WITH_DRIVER_MODULES
+mod_LTLIBRARIES += libvirt_driver_vbox.la
+else
+noinst_LTLIBRARIES += libvirt_driver_vbox.la
+libvirt_la_LIBADD += libvirt_driver_vbox.la
+endif
+if WITH_DRIVER_MODULES
+libvirt_driver_vbox_la_LDFLAGS = -module -avoid-version
+endif
+libvirt_driver_vbox_la_SOURCES = $(VBOX_DRIVER_SOURCES)
+endif
+
 if WITH_QEMU
 if WITH_DRIVER_MODULES
 mod_LTLIBRARIES += libvirt_driver_qemu.la
@@ -403,6 +421,7 @@ EXTRA_DIST +=							\
 		$(LXC_DRIVER_SOURCES)				\
 		$(UML_DRIVER_SOURCES)				\
 		$(OPENVZ_DRIVER_SOURCES)			\
+		$(VBOX_DRIVER_SOURCES)				\
 		$(NETWORK_DRIVER_SOURCES)			\
 		$(STORAGE_DRIVER_SOURCES)			\
 		$(STORAGE_DRIVER_FS_SOURCES)			\
diff --git a/src/domain_conf.c b/src/domain_conf.c
index 5bf3483..8a0d0bb 100644
--- a/src/domain_conf.c
+++ b/src/domain_conf.c
@@ -54,7 +54,8 @@ VIR_ENUM_IMPL(virDomainVirt, VIR_DOMAIN_VIRT_LAST,
               "ldom",
               "test",
               "vmware",
-              "hyperv")
+              "hyperv",
+              "vbox")
 
 VIR_ENUM_IMPL(virDomainBoot, VIR_DOMAIN_BOOT_LAST,
               "fd",
diff --git a/src/domain_conf.h b/src/domain_conf.h
index dd61467..f4eea6b 100644
--- a/src/domain_conf.h
+++ b/src/domain_conf.h
@@ -48,6 +48,7 @@ enum virDomainVirtType {
     VIR_DOMAIN_VIRT_TEST,
     VIR_DOMAIN_VIRT_VMWARE,
     VIR_DOMAIN_VIRT_HYPERV,
+    VIR_DOMAIN_VIRT_VBOX,
 
     VIR_DOMAIN_VIRT_LAST,
 };
diff --git a/src/driver.h b/src/driver.h
index 62d6fbc..4d7603b 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -20,6 +20,7 @@ typedef enum {
     VIR_DRV_OPENVZ = 5,
     VIR_DRV_LXC = 6,
     VIR_DRV_UML = 7,
+    VIR_DRV_VBOX = 8,
 } virDrvNo;
 
 
diff --git a/src/libvirt.c b/src/libvirt.c
index f29df6b..b8b663e 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -55,6 +55,9 @@
 #ifdef WITH_OPENVZ
 #include "openvz_driver.h"
 #endif
+#ifdef WITH_VBOX
+#include "vbox/vbox_driver.h"
+#endif
 #endif
 
 #define VIR_FROM_THIS VIR_FROM_NONE
@@ -306,6 +309,7 @@ virInitialize(void)
     virDriverLoadModule("test");
     virDriverLoadModule("xen");
     virDriverLoadModule("openvz");
+    virDriverLoadModule("vbox");
     virDriverLoadModule("remote");
 #else
 #ifdef WITH_TEST
@@ -317,6 +321,9 @@ virInitialize(void)
 #ifdef WITH_OPENVZ
     if (openvzRegister() == -1) return -1;
 #endif
+#ifdef WITH_VBOX
+    if (vboxRegister() == -1) return -1;
+#endif
 #ifdef WITH_REMOTE
     if (remoteRegister () == -1) return -1;
 #endif
@@ -830,6 +837,10 @@ virGetVersion(unsigned long *libVer, const char *type,
         if (STRCASEEQ(type, "OpenVZ"))
             *typeVer = LIBVIR_VERSION_NUMBER;
 #endif
+#if WITH_VBOX
+        if (STRCASEEQ(type, "VBox"))
+            *typeVer = LIBVIR_VERSION_NUMBER;
+#endif
 #if WITH_UML
         if (STRCASEEQ(type, "UML"))
             *typeVer = LIBVIR_VERSION_NUMBER;
diff --git a/src/virterror.c b/src/virterror.c
index d2514db..b4e5e3d 100644
--- a/src/virterror.c
+++ b/src/virterror.c
@@ -153,6 +153,8 @@ static const char *virErrorDomainName(virErrorDomain domain) {
             break;
         case VIR_FROM_SECURITY:
             dom = "Security Labeling ";
+        case VIR_FROM_VBOX:
+            dom = "VBOX ";
             break;
     }
     return(dom);
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to