Skip to content

Instantly share code, notes, and snippets.

@wez wez/fusion.diff
Created Jan 29, 2012

Embed
What would you like to do?
vmware fusion support for libvert
diff -ur libvirt-0.9.9/src/vmware/vmware_conf.c /Users/wez/src/libvirt-0.9.9/src/vmware/vmware_conf.c
--- libvirt-0.9.9/src/vmware/vmware_conf.c 2011-11-03 10:48:23.000000000 -0400
+++ /Users/wez/src/libvirt-0.9.9/src/vmware/vmware_conf.c 2012-01-29 09:47:55.000000000 -0500
@@ -157,7 +157,7 @@
ctx.parseFileName = vmwareCopyVMXFileName;
cmd = virCommandNewArgList(VMRUN, "-T",
- driver->type == TYPE_PLAYER ? "player" : "ws",
+ vmw_types[driver->type],
"list", NULL);
virCommandSetOutputBuffer(cmd, &outbuf);
if (virCommandRun(cmd, NULL) < 0)
@@ -241,19 +241,37 @@
int ret = -1;
virCommandPtr cmd;
char * outbuf = NULL;
- const char * bin = (driver->type == TYPE_PLAYER) ? "vmplayer" : "vmware";
- const char * pattern = (driver->type == TYPE_PLAYER) ?
- "VMware Player " : "VMware Workstation ";
+ const char * bin;
+ const char * pattern;
+
+ switch (driver->type) {
+ case TYPE_PLAYER:
+ bin = "vmplayer";
+ pattern = "VMware Player";
+ break;
+ case TYPE_WORKSTATION:
+ bin = "vmware";
+ pattern = "VMware Workstation";
+ break;
+ case TYPE_FUSION:
+ bin = "vmware-vmx";
+ pattern = "\nVMware Fusion Information:\nVMware Fusion";
+ break;
+ }
cmd = virCommandNewArgList(bin, "-v", NULL);
- virCommandSetOutputBuffer(cmd, &outbuf);
+
+ if (driver->type == TYPE_FUSION) {
+ virCommandSetErrorBuffer(cmd, &outbuf);
+ } else {
+ virCommandSetOutputBuffer(cmd, &outbuf);
+ }
if (virCommandRun(cmd, NULL) < 0)
goto cleanup;
-
if ((tmp = STRSKIP(outbuf, pattern)) == NULL) {
vmwareError(VIR_ERR_INTERNAL_ERROR,
- _("failed to parse %s version"), bin);
+ _("failed to parse %s version %s"), bin, outbuf);
goto cleanup;
}
diff -ur libvirt-0.9.9/src/vmware/vmware_conf.h /Users/wez/src/libvirt-0.9.9/src/vmware/vmware_conf.h
--- libvirt-0.9.9/src/vmware/vmware_conf.h 2011-06-10 02:50:15.000000000 -0400
+++ /Users/wez/src/libvirt-0.9.9/src/vmware/vmware_conf.h 2012-01-29 09:47:35.000000000 -0500
@@ -36,6 +36,7 @@
# define TYPE_PLAYER 0
# define TYPE_WORKSTATION 1
+# define TYPE_FUSION 2
struct vmware_driver {
virMutex lock;
@@ -52,6 +53,8 @@
} vmwareDomain, *vmwareDomainPtr;
+static const char *vmw_types[] = { "player", "ws", "fusion" };
+
void vmwareFreeDriver(struct vmware_driver *driver);
virCapsPtr vmwareCapsInit(void);
diff -ur libvirt-0.9.9/src/vmware/vmware_driver.c /Users/wez/src/libvirt-0.9.9/src/vmware/vmware_driver.c
--- libvirt-0.9.9/src/vmware/vmware_driver.c 2011-12-01 22:59:50.000000000 -0500
+++ /Users/wez/src/libvirt-0.9.9/src/vmware/vmware_driver.c 2012-01-29 09:47:29.000000000 -0500
@@ -34,8 +34,6 @@
#include "vmware_conf.h"
#include "vmware_driver.h"
-static const char *vmw_types[] = { "player", "ws" };
-
static void
vmwareDriverLock(struct vmware_driver *driver)
{
@@ -87,6 +85,7 @@
} else {
if (conn->uri->scheme == NULL ||
(STRNEQ(conn->uri->scheme, "vmwareplayer") &&
+ STRNEQ(conn->uri->scheme, "vmwarefusion") &&
STRNEQ(conn->uri->scheme, "vmwarews")))
return VIR_DRV_OPEN_DECLINED;
@@ -125,7 +124,9 @@
goto cleanup;
driver->type = STRNEQ(conn->uri->scheme, "vmwareplayer") ?
- TYPE_WORKSTATION : TYPE_PLAYER;
+ (STRNEQ(conn->uri->scheme, "vmwarews") ?
+ TYPE_FUSION : TYPE_WORKSTATION) :
+ TYPE_PLAYER;
if (virDomainObjListInit(&driver->domains) < 0)
goto cleanup;
diff -ur libvirt-0.9.9/src/vmx/vmx.c /Users/wez/src/libvirt-0.9.9/src/vmx/vmx.c
--- libvirt-0.9.9/src/vmx/vmx.c 2011-12-01 22:59:56.000000000 -0500
+++ /Users/wez/src/libvirt-0.9.9/src/vmx/vmx.c 2012-01-29 10:05:03.000000000 -0500
@@ -2448,10 +2448,20 @@
goto cleanup;
} else if (STRCASEEQ(connectionType, "nat")) {
/* FIXME */
+ (*def)->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
+ (*def)->model = virtualDev;
+ (*def)->data.bridge.brname = networkName;
+ (*def)->ifname = vnet;
+
+ virtualDev = NULL;
+ networkName = NULL;
+ vnet = NULL;
+#if 0
VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("No yet handled value '%s' for VMX entry '%s'"),
connectionType, connectionType_name);
goto cleanup;
+#endif
} else if (STRCASEEQ(connectionType, "custom")) {
(*def)->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
(*def)->model = virtualDev;
@@ -2568,7 +2578,8 @@
}
/* vmx:fileName -> def:data.file.path */
- if (virVMXGetConfigString(conf, fileName_name, &fileName, false) < 0) {
+ if (virVMXGetConfigString(conf, fileName_name, &fileName,
+ STREQ(fileType, "thinprint")) < 0) {
goto cleanup;
}
@@ -2585,6 +2596,8 @@
(*def)->source.data.file.path = fileName;
fileName = NULL;
+ } else if (STRCASEEQ(fileType, "thinprint")) {
+ /* NOP */
} else if (STRCASEEQ(fileType, "file")) {
(*def)->target.port = port;
(*def)->source.type = VIR_DOMAIN_CHR_TYPE_FILE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.