[PATCH] bhyve: implement virConnectGetDomainCapabilities

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

 



This patch adds virConnectGetDomainCapabilities support for bhyve.

---
 src/bhyve/bhyve_capabilities.c | 26 ++++++++++++++++++++
 src/bhyve/bhyve_capabilities.h |  5 ++++
 src/bhyve/bhyve_driver.c       | 56 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 87 insertions(+)

diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c
index d0af4d9..10c33b9 100644
--- a/src/bhyve/bhyve_capabilities.c
+++ b/src/bhyve/bhyve_capabilities.c
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 2014 Roman Bogorodskiy
  * Copyright (C) 2014 Semihalf
+ * Copyright (C) 2016 Fabian Freyer
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -106,6 +107,31 @@ virBhyveCapsBuild(void)
     return NULL;
 }
 
+virDomainCapsPtr
+virBhyveDomainCapsBuild(const char *emulatorbin,
+                        const char *machine,
+                        virArch arch,
+                        virDomainVirtType virttype)
+{
+    virDomainCapsPtr caps = NULL;
+
+    if (!(caps = virDomainCapsNew(emulatorbin, machine, arch, virttype)))
+        goto cleanup;
+
+    caps->os.supported = true;
+    caps->disk.supported = true;
+    VIR_DOMAIN_CAPS_ENUM_SET(caps->disk.diskDevice,
+                             VIR_DOMAIN_DISK_DEVICE_DISK,
+                             VIR_DOMAIN_DISK_DEVICE_CDROM);
+
+    VIR_DOMAIN_CAPS_ENUM_SET(caps->disk.bus,
+                             VIR_DOMAIN_DISK_BUS_SATA,
+                             VIR_DOMAIN_DISK_BUS_VIRTIO);
+
+ cleanup:
+    return caps;
+}
+
 int
 virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps)
 {
diff --git a/src/bhyve/bhyve_capabilities.h b/src/bhyve/bhyve_capabilities.h
index 0eb22a4..85018cb 100644
--- a/src/bhyve/bhyve_capabilities.h
+++ b/src/bhyve/bhyve_capabilities.h
@@ -23,8 +23,13 @@
 # define _BHYVE_CAPABILITIES
 
 # include "capabilities.h"
+#include "conf/domain_capabilities.h"
 
 virCapsPtr virBhyveCapsBuild(void);
+virDomainCapsPtr virBhyveDomainCapsBuild(const char *emulatorbin,
+                                         const char *machine,
+                                         virArch arch,
+                                         virDomainVirtType virttype);
 
 /* These are bit flags: */
 typedef enum {
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 8036661..ae37a2d 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -53,6 +53,7 @@
 #include "nodeinfo.h"
 #include "virhostcpu.h"
 #include "virhostmem.h"
+#include "conf/domain_capabilities.h"
 
 #include "bhyve_device.h"
 #include "bhyve_driver.h"
@@ -1539,6 +1540,60 @@ bhyveConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
     return 0;
 }
 
+static char *
+bhyveConnectGetDomainCapabilities(virConnectPtr conn,
+                                  const char *emulatorbin,
+                                  const char *arch_str,
+                                  const char *machine,
+                                  const char *virttype_str,
+                                  unsigned int flags)
+{
+    //bhyveConnPtr privconn = conn->privateData;
+    virDomainCapsPtr caps = NULL;
+    char *ret = NULL;
+    int virttype = VIR_DOMAIN_VIRT_BHYVE;
+    int arch = virArchFromHost(); /* virArch */
+
+    virCheckFlags(0, ret);
+
+    if (virConnectGetDomainCapabilitiesEnsureACL(conn) < 0)
+        return ret;
+
+    if (virttype_str &&
+        (virttype = virDomainVirtTypeFromString(virttype_str)) < 0) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("unknown virttype: %s"),
+                       virttype_str);
+        goto cleanup;
+    }
+
+    if (virttype != VIR_DOMAIN_VIRT_BHYVE) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("unknown virttype: %s"),
+                       virttype_str);
+        goto cleanup;
+    }
+
+    if (arch_str && (arch = virArchFromString(arch_str)) == VIR_ARCH_NONE) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("unknown architecture: %s"),
+                       arch_str);
+        goto cleanup;
+    }
+
+    if (emulatorbin == NULL)
+        emulatorbin = "/usr/sbin/bhyve";
+
+    if (!(caps = virBhyveDomainCapsBuild(emulatorbin, machine, arch, virttype)))
+        goto cleanup;
+
+    ret = virDomainCapsFormat(caps);
+
+ cleanup:
+    virObjectUnref(caps);
+    return ret;
+}
+
 static virHypervisorDriver bhyveHypervisorDriver = {
     .name = "bhyve",
     .connectOpen = bhyveConnectOpen, /* 1.2.2 */
@@ -1592,6 +1647,7 @@ static virHypervisorDriver bhyveHypervisorDriver = {
     .connectIsAlive = bhyveConnectIsAlive, /* 1.3.5 */
     .connectIsSecure = bhyveConnectIsSecure, /* 1.3.5 */
     .connectIsEncrypted = bhyveConnectIsEncrypted, /* 1.3.5 */
+    .connectGetDomainCapabilities = bhyveConnectGetDomainCapabilities, /* 2.1.0 */
 };
 
 
-- 
2.5.5

--
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]