It's no longer used. Remove the dead code.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/libvirt_xenconfig.syms | 4 -
src/xenconfig/xen_sxpr.c | 880 -------------------------------------
src/xenconfig/xen_sxpr.h | 12 -
3 files changed, 896 deletions(-)
diff --git a/src/libvirt_xenconfig.syms b/src/libvirt_xenconfig.syms
index b69f2ab493..945f16e382 100644
--- a/src/libvirt_xenconfig.syms
+++ b/src/libvirt_xenconfig.syms
@@ -3,11 +3,7 @@
#
# xenconfig/xen_sxpr.h
-xenFormatSxpr;
xenFormatSxprChr;
-xenFormatSxprDisk;
-xenFormatSxprNet;
-xenFormatSxprOnePCI;
xenFormatSxprSound;
xenGetDomIdFromSxpr;
xenGetDomIdFromSxprString;
diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c
index 0bff94ead5..d67a89efee 100644
--- a/src/xenconfig/xen_sxpr.c
+++ b/src/xenconfig/xen_sxpr.c
@@ -28,7 +28,6 @@
#include "virerror.h"
#include "virconf.h"
#include "viralloc.h"
-#include "verify.h"
#include "viruuid.h"
#include "virlog.h"
#include "count-one-bits.h"
@@ -1493,121 +1492,6 @@ xenParseSxprString(const char *sexpr,
return def;
}
-/************************************************************************
- * *
- * Converter functions to go from the XML tree to an S-Expr for Xen *
- * *
- ************************************************************************/
-
-
-/**
- * xenFormatSxprGraphicsNew:
- * @def: the domain config
- * @buf: a buffer for the result S-expression
- *
- * Convert the graphics part of the domain description into a S-expression
- * in buf. (HVM > 3.0.4 or PV > 3.0.3)
- *
- * Returns 0 in case of success, -1 in case of error
- */
-static int
-xenFormatSxprGraphicsNew(virDomainGraphicsDefPtr def,
- virBufferPtr buf)
-{
- virDomainGraphicsListenDefPtr glisten;
-
- if (def->type != VIR_DOMAIN_GRAPHICS_TYPE_SDL &&
- def->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unexpected graphics type %d"),
- def->type);
- return -1;
- }
-
- virBufferAddLit(buf, "(device (vkbd))");
- virBufferAddLit(buf, "(device (vfb ");
-
- if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) {
- virBufferAddLit(buf, "(type sdl)");
- if (def->data.sdl.display)
- virBufferAsprintf(buf, "(display '%s')",
def->data.sdl.display);
- if (def->data.sdl.xauth)
- virBufferAsprintf(buf, "(xauthority '%s')",
def->data.sdl.xauth);
- } else if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
- virBufferAddLit(buf, "(type vnc)");
- if (def->data.vnc.autoport) {
- virBufferAddLit(buf, "(vncunused 1)");
- } else {
- virBufferAddLit(buf, "(vncunused 0)");
- virBufferAsprintf(buf, "(vncdisplay %d)",
def->data.vnc.port-5900);
- }
-
- if ((glisten = virDomainGraphicsGetListen(def, 0)) &&
- glisten->address)
- virBufferAsprintf(buf, "(vnclisten '%s')",
glisten->address);
- if (def->data.vnc.auth.passwd)
- virBufferAsprintf(buf, "(vncpasswd '%s')",
def->data.vnc.auth.passwd);
- if (def->data.vnc.keymap)
- virBufferAsprintf(buf, "(keymap '%s')",
def->data.vnc.keymap);
- }
-
- virBufferAddLit(buf, "))");
-
- return 0;
-}
-
-
-/**
- * xenFormatSxprGraphicsOld:
- * @def: the domain config
- * @buf: a buffer for the result S-expression
- *
- * Convert the graphics part of the domain description into a S-expression
- * in buf. (HVM <= 3.0.4 or PV <= 3.0.3)
- *
- * Returns 0 in case of success, -1 in case of error
- */
-static int
-xenFormatSxprGraphicsOld(virDomainGraphicsDefPtr def, virBufferPtr buf)
-{
- virDomainGraphicsListenDefPtr glisten;
-
- if (def->type != VIR_DOMAIN_GRAPHICS_TYPE_SDL &&
- def->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unexpected graphics type %d"),
- def->type);
- return -1;
- }
-
- if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) {
- virBufferAddLit(buf, "(sdl 1)");
- if (def->data.sdl.display)
- virBufferAsprintf(buf, "(display '%s')",
def->data.sdl.display);
- if (def->data.sdl.xauth)
- virBufferAsprintf(buf, "(xauthority '%s')",
def->data.sdl.xauth);
- } else if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
- virBufferAddLit(buf, "(vnc 1)");
- if (def->data.vnc.autoport) {
- virBufferAddLit(buf, "(vncunused 1)");
- } else {
- virBufferAddLit(buf, "(vncunused 0)");
- virBufferAsprintf(buf, "(vncdisplay %d)",
def->data.vnc.port-5900);
- }
-
- if ((glisten = virDomainGraphicsGetListen(def, 0)) &&
- glisten->address)
- virBufferAsprintf(buf, "(vnclisten '%s')",
glisten->address);
- if (def->data.vnc.auth.passwd)
- virBufferAsprintf(buf, "(vncpasswd '%s')",
def->data.vnc.auth.passwd);
- if (def->data.vnc.keymap)
- virBufferAsprintf(buf, "(keymap '%s')",
def->data.vnc.keymap);
- }
-
- return 0;
-}
-
-
/**
* xenFormatSxprChr:
* @def: the domain config
@@ -1687,382 +1571,6 @@ xenFormatSxprChr(virDomainChrDefPtr def,
}
-/**
- * xenFormatSxprDisk:
- * @node: node containing the disk description
- * @buf: a buffer for the result S-expression
- * @hvm: true or 1 if domain is HVM
- * @isAttach: create expression for device attach (1).
- *
- * Convert the disk device part of the domain config into a S-expression in buf.
- *
- * Returns 0 in case of success, -1 in case of error.
- */
-int
-xenFormatSxprDisk(virDomainDiskDefPtr def,
- virBufferPtr buf,
- int hvm,
- int isAttach)
-{
- const char *src = virDomainDiskGetSource(def);
- const char *driver = virDomainDiskGetDriver(def);
-
- /* Xend (all versions) put the floppy device config
- * under the hvm (image (os)) block
- */
- if (hvm &&
- def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
- if (isAttach) {
- virReportError(VIR_ERR_INVALID_ARG,
- _("Cannot directly attach floppy %s"), src);
- return -1;
- }
- return 0;
- }
-
- if (!isAttach)
- virBufferAddLit(buf, "(device ");
-
- /* Normally disks are in a (device (vbd ...)) block
- * but blktap disks ended up in a differently named
- * (device (tap ....)) block.... */
- if (STREQ_NULLABLE(driver, "tap")) {
- virBufferAddLit(buf, "(tap ");
- } else if (STREQ_NULLABLE(driver, "tap2")) {
- virBufferAddLit(buf, "(tap2 ");
- } else {
- virBufferAddLit(buf, "(vbd ");
- }
-
- if (hvm) {
- virBufferEscapeSexpr(buf, "(dev '%s:", def->dst);
- virBufferAsprintf(buf, "%s')",
- def->device == VIR_DOMAIN_DISK_DEVICE_CDROM ?
- "cdrom" : "disk");
- } else if (def->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
- virBufferEscapeSexpr(buf, "(dev '%s:cdrom')", def->dst);
- } else {
- virBufferEscapeSexpr(buf, "(dev '%s')", def->dst);
- }
-
- if (src) {
- if (driver) {
- if (STREQ(driver, "tap") ||
- STREQ(driver, "tap2")) {
- const char *type;
- int format = virDomainDiskGetFormat(def);
-
- if (!format || format == VIR_STORAGE_FILE_RAW)
- type = "aio";
- else
- type = virStorageFileFormatTypeToString(format);
- virBufferEscapeSexpr(buf, "(uname '%s:", driver);
- virBufferEscapeSexpr(buf, "%s:", type);
- virBufferEscapeSexpr(buf, "%s')", src);
- } else {
- virBufferEscapeSexpr(buf, "(uname '%s:", driver);
- virBufferEscapeSexpr(buf, "%s')", src);
- }
- } else {
- int type = virDomainDiskGetType(def);
-
- if (type == VIR_STORAGE_TYPE_FILE) {
- virBufferEscapeSexpr(buf, "(uname 'file:%s')", src);
- } else if (type == VIR_STORAGE_TYPE_BLOCK) {
- if (src[0] == '/')
- virBufferEscapeSexpr(buf, "(uname 'phy:%s')",
src);
- else
- virBufferEscapeSexpr(buf, "(uname 'phy:/dev/%s')",
- src);
- } else {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unsupported disk type %s"),
- virStorageTypeToString(type));
- return -1;
- }
- }
- }
-
- if (def->src->readonly)
- virBufferAddLit(buf, "(mode 'r')");
- else if (def->src->shared)
- virBufferAddLit(buf, "(mode 'w!')");
- else
- virBufferAddLit(buf, "(mode 'w')");
- if (def->transient) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("transient disks not supported yet"));
- return -1;
- }
-
- if (!isAttach)
- virBufferAddLit(buf, ")");
-
- virBufferAddLit(buf, ")");
-
- return 0;
-}
-
-/**
- * xenFormatSxprNet:
- * @conn: connection
- * @def: the domain config
- * @buf: a buffer for the result S-expression
- * @hvm: true or 1 if domain is HVM
- * @isAttach: create expression for device attach (1).
- *
- * Convert the interface description of the domain config into a S-expression in buf.
- * This is a temporary interface as the S-Expr interface
- * will be replaced by XML-RPC in the future. However the XML format should
- * stay valid over time.
- *
- * Returns 0 in case of success, -1 in case of error.
- */
-int
-xenFormatSxprNet(virConnectPtr conn,
- virDomainNetDefPtr def,
- virBufferPtr buf,
- int hvm,
- int isAttach)
-{
- const char *script = DEFAULT_VIF_SCRIPT;
- char macaddr[VIR_MAC_STRING_BUFLEN];
-
- if (def->type != VIR_DOMAIN_NET_TYPE_BRIDGE &&
- def->type != VIR_DOMAIN_NET_TYPE_NETWORK &&
- def->type != VIR_DOMAIN_NET_TYPE_ETHERNET) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unsupported network type %d"), def->type);
- return -1;
- }
- if (def->script &&
- def->type != VIR_DOMAIN_NET_TYPE_BRIDGE &&
- def->type != VIR_DOMAIN_NET_TYPE_ETHERNET) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("scripts are not supported on interfaces of type
%s"),
- virDomainNetTypeToString(def->type));
- return -1;
- }
-
- if (!isAttach)
- virBufferAddLit(buf, "(device ");
-
- virBufferAddLit(buf, "(vif ");
-
- virBufferAsprintf(buf, "(mac '%s')",
virMacAddrFormat(&def->mac, macaddr));
-
- if (def->bandwidth && def->bandwidth->out &&
def->bandwidth->out->average)
- virBufferAsprintf(buf, "(rate '%lluKB/s')",
def->bandwidth->out->average);
-
- switch (def->type) {
- case VIR_DOMAIN_NET_TYPE_BRIDGE:
- virBufferEscapeSexpr(buf, "(bridge '%s')",
def->data.bridge.brname);
- if (def->script)
- script = def->script;
-
- virBufferEscapeSexpr(buf, "(script '%s')", script);
- if (def->guestIP.nips == 1) {
- char *ipStr = virSocketAddrFormat(&def->guestIP.ips[0]->address);
- virBufferEscapeSexpr(buf, "(ip '%s')", ipStr);
- VIR_FREE(ipStr);
- } else if (def->guestIP.nips > 1) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("Driver does not support setting multiple IP
addresses"));
- return -1;
- }
- break;
-
- case VIR_DOMAIN_NET_TYPE_NETWORK:
- {
- virNetworkPtr network =
- virNetworkLookupByName(conn, def->data.network.name);
- char *bridge;
-
- if (!network) {
- virReportError(VIR_ERR_NO_NETWORK, "%s",
- def->data.network.name);
- return -1;
- }
-
- bridge = virNetworkGetBridgeName(network);
- virObjectUnref(network);
- if (!bridge) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("network %s is not active"),
- def->data.network.name);
- return -1;
- }
- virBufferEscapeSexpr(buf, "(bridge '%s')", bridge);
- virBufferEscapeSexpr(buf, "(script '%s')", script);
- VIR_FREE(bridge);
- }
- break;
-
- case VIR_DOMAIN_NET_TYPE_ETHERNET:
- if (def->script)
- virBufferEscapeSexpr(buf, "(script '%s')",
- def->script);
- if (def->guestIP.nips == 1) {
- char *ipStr = virSocketAddrFormat(&def->guestIP.ips[0]->address);
- virBufferEscapeSexpr(buf, "(ip '%s')", ipStr);
- VIR_FREE(ipStr);
- } else if (def->guestIP.nips > 1) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("Driver does not support setting multiple IP
addresses"));
- return -1;
- }
- break;
-
- case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
- case VIR_DOMAIN_NET_TYPE_USER:
- case VIR_DOMAIN_NET_TYPE_SERVER:
- case VIR_DOMAIN_NET_TYPE_CLIENT:
- case VIR_DOMAIN_NET_TYPE_MCAST:
- case VIR_DOMAIN_NET_TYPE_UDP:
- case VIR_DOMAIN_NET_TYPE_INTERNAL:
- case VIR_DOMAIN_NET_TYPE_DIRECT:
- case VIR_DOMAIN_NET_TYPE_HOSTDEV:
- case VIR_DOMAIN_NET_TYPE_LAST:
- break;
- }
-
- if (def->ifname != NULL &&
- !STRPREFIX(def->ifname, "vif"))
- virBufferEscapeSexpr(buf, "(vifname '%s')", def->ifname);
-
- if (virDomainNetGetModelString(def)) {
- if (!hvm) {
- virBufferEscapeSexpr(buf, "(model '%s')",
- virDomainNetGetModelString(def));
- } else {
- if (def->model == VIR_DOMAIN_NET_MODEL_NETFRONT)
- virBufferAddLit(buf, "(type netfront)");
- else
- virBufferEscapeSexpr(buf, "(model '%s')",
- virDomainNetGetModelString(def));
- }
- }
-
- if (!isAttach)
- virBufferAddLit(buf, ")");
-
- virBufferAddLit(buf, ")");
-
- return 0;
-}
-
-
-/**
- * xenFormatSxprPCI:
- * @def: the device config
- * @buf: a buffer for the result S-expression
- *
- * Convert a single PCI device part of the domain config into a S-expression in buf.
- *
- * Returns 0 in case of success, -1 in case of error.
- */
-static void
-xenFormatSxprPCI(virDomainHostdevDefPtr def,
- virBufferPtr buf)
-{
- virBufferAsprintf(buf, "(dev (domain 0x%04x)(bus 0x%02x)(slot 0x%02x)(func
0x%x))",
- def->source.subsys.u.pci.addr.domain,
- def->source.subsys.u.pci.addr.bus,
- def->source.subsys.u.pci.addr.slot,
- def->source.subsys.u.pci.addr.function);
-}
-
-
-/**
- * xenFormatSxprOnePCI:
- * @def: the device config
- * @buf: a buffer for the result S-expression
- * @detach: create expression for device detach (1).
- *
- * Convert a single PCI device part of the domain config into a S-expression in buf.
- *
- * Returns 0 in case of success, -1 in case of error.
- */
-int
-xenFormatSxprOnePCI(virDomainHostdevDefPtr def,
- virBufferPtr buf,
- int detach)
-{
- if (def->managed) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("managed PCI devices not supported with XenD"));
- return -1;
- }
-
- virBufferAddLit(buf, "(pci ");
- xenFormatSxprPCI(def, buf);
- if (detach)
- virBufferAddLit(buf, "(state 'Closing')");
- else
- virBufferAddLit(buf, "(state 'Initialising')");
- virBufferAddLit(buf, ")");
-
- return 0;
-}
-
-
-/**
- * xenFormatSxprAllPCI:
- * @def: the domain config
- * @buf: a buffer for the result S-expression
- *
- * Convert all PCI device parts of the domain config into a S-expression in buf.
- *
- * Returns 0 in case of success, -1 in case of error.
- */
-static int
-xenFormatSxprAllPCI(virDomainDefPtr def,
- virBufferPtr buf)
-{
- int hasPCI = 0;
- size_t i;
-
- for (i = 0; i < def->nhostdevs; i++)
- if (def->hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
- def->hostdevs[i]->source.subsys.type ==
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
- hasPCI = 1;
-
- if (!hasPCI)
- return 0;
-
- /*
- * With the (domain ...) block we have the following odd setup
- *
- * (device
- * (pci
- * (dev (domain 0x0000) (bus 0x00) (slot 0x1b) (func 0x0))
- * (dev (domain 0x0000) (bus 0x00) (slot 0x13) (func 0x0))
- * )
- * )
- *
- * Normally there is one (device ...) block per device, but in the
- * weird world of Xen PCI, one (device ...) covers multiple devices.
- */
-
- virBufferAddLit(buf, "(device (pci ");
- for (i = 0; i < def->nhostdevs; i++) {
- if (def->hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
- def->hostdevs[i]->source.subsys.type ==
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
- if (def->hostdevs[i]->managed) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("managed PCI devices not supported with
XenD"));
- return -1;
- }
-
- xenFormatSxprPCI(def->hostdevs[i], buf);
- }
- }
- virBufferAddLit(buf, "))");
-
- return 0;
-}
-
-
/**
* xenFormatSxprSound:
* @def: the domain config
@@ -2096,391 +1604,3 @@ xenFormatSxprSound(virDomainDefPtr def,
return 0;
}
-
-
-/**
- * xenFormatSxprInput:
- * @input: the input config
- * @buf: a buffer for the result S-expression
- *
- * Convert all input device parts of the domain config into S-expression in buf.
- *
- * Returns 0 if successful or -1 if failed.
- */
-static int
-xenFormatSxprInput(virDomainInputDefPtr input,
- virBufferPtr buf)
-{
- if (input->bus != VIR_DOMAIN_INPUT_BUS_USB)
- return 0;
-
- if (input->type != VIR_DOMAIN_INPUT_TYPE_MOUSE &&
- input->type != VIR_DOMAIN_INPUT_TYPE_TABLET &&
- input->type != VIR_DOMAIN_INPUT_TYPE_KBD) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unexpected input type %d"), input->type);
- return -1;
- }
-
- switch (input->type) {
- case VIR_DOMAIN_INPUT_TYPE_MOUSE:
- virBufferAsprintf(buf, "(usbdevice %s)", "mouse");
- break;
- case VIR_DOMAIN_INPUT_TYPE_TABLET:
- virBufferAsprintf(buf, "(usbdevice %s)", "tablet");
- break;
- case VIR_DOMAIN_INPUT_TYPE_KBD:
- virBufferAsprintf(buf, "(usbdevice %s)", "keyboard");
- break;
- }
-
- return 0;
-}
-
-
-/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
- either 32, or 64 on a platform where long is big enough. */
-verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT);
-
-/**
- * xenFormatSxpr:
- * @conn: pointer to the hypervisor connection
- * @def: domain config definition
- *
- * Generate an S-expression representing the domain configuration.
- *
- * Returns the 0 terminated S-Expr string or NULL in case of error.
- * the caller must free() the returned value.
- */
-char *
-xenFormatSxpr(virConnectPtr conn, virDomainDefPtr def)
-{
- virBuffer buf = VIR_BUFFER_INITIALIZER;
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- const char *tmp;
- char *bufout;
- int hvm = 0, vmlocaltime = -1;
- size_t i;
- bool in_image = false;
-
- VIR_DEBUG("Formatting domain sexpr");
-
- virBufferAddLit(&buf, "(vm ");
- virBufferEscapeSexpr(&buf, "(name '%s')", def->name);
- virBufferAsprintf(&buf, "(memory %llu)(maxmem %llu)",
- VIR_DIV_UP(def->mem.cur_balloon, 1024),
- VIR_DIV_UP(virDomainDefGetMemoryTotal(def), 1024));
- virBufferAsprintf(&buf, "(vcpus %u)", virDomainDefGetVcpusMax(def));
- /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
- either 32, or 64 on a platform where long is big enough. */
- if (virDomainDefHasVcpusOffline(def))
- virBufferAsprintf(&buf, "(vcpu_avail %lu)",
- (1UL << virDomainDefGetVcpus(def)) - 1);
-
- if (def->cpumask) {
- char *ranges = virBitmapFormat(def->cpumask);
- if (ranges == NULL)
- goto error;
- virBufferEscapeSexpr(&buf, "(cpus '%s')", ranges);
- VIR_FREE(ranges);
- }
-
- virUUIDFormat(def->uuid, uuidstr);
- virBufferAsprintf(&buf, "(uuid '%s')", uuidstr);
-
- if (def->description)
- virBufferEscapeSexpr(&buf, "(description '%s')",
def->description);
-
- if (def->os.bootloader) {
- if (def->os.bootloader[0])
- virBufferEscapeSexpr(&buf, "(bootloader '%s')",
def->os.bootloader);
- else
- virBufferAddLit(&buf, "(bootloader)");
-
- if (def->os.bootloaderArgs)
- virBufferEscapeSexpr(&buf, "(bootloader_args '%s')",
def->os.bootloaderArgs);
- }
-
- if (!(tmp = virDomainLifecycleActionTypeToString(def->onPoweroff))) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unexpected lifecycle value %d"),
def->onPoweroff);
- goto error;
- }
- virBufferAsprintf(&buf, "(on_poweroff '%s')", tmp);
-
- if (!(tmp = virDomainLifecycleActionTypeToString(def->onReboot))) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unexpected lifecycle value %d"), def->onReboot);
- goto error;
- }
- virBufferAsprintf(&buf, "(on_reboot '%s')", tmp);
-
- if (!(tmp = virDomainLifecycleActionTypeToString(def->onCrash))) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unexpected lifecycle value %d"), def->onCrash);
- goto error;
- }
- virBufferAsprintf(&buf, "(on_crash '%s')", tmp);
-
- if (def->os.type == VIR_DOMAIN_OSTYPE_HVM)
- hvm = 1;
-
- if (!def->os.bootloader) {
- if (hvm)
- virBufferAddLit(&buf, "(image (hvm ");
- else
- virBufferAddLit(&buf, "(image (linux ");
- in_image = true;
-
- if (hvm &&
- def->os.loader == NULL) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("no HVM domain loader"));
- goto error;
- }
-
- if (def->os.kernel)
- virBufferEscapeSexpr(&buf, "(kernel '%s')",
def->os.kernel);
- if (def->os.initrd)
- virBufferEscapeSexpr(&buf, "(ramdisk '%s')",
def->os.initrd);
- if (def->os.root)
- virBufferEscapeSexpr(&buf, "(root '%s')",
def->os.root);
- if (def->os.cmdline)
- virBufferEscapeSexpr(&buf, "(args '%s')",
def->os.cmdline);
-
- if (hvm) {
- char bootorder[VIR_DOMAIN_BOOT_LAST+1];
- if (def->os.kernel)
- virBufferEscapeSexpr(&buf, "(loader '%s')",
def->os.loader->path);
- else
- virBufferEscapeSexpr(&buf, "(kernel '%s')",
def->os.loader->path);
-
- virBufferAsprintf(&buf, "(vcpus %u)",
virDomainDefGetVcpusMax(def));
- if (virDomainDefHasVcpusOffline(def))
- virBufferAsprintf(&buf, "(vcpu_avail %lu)",
- (1UL << virDomainDefGetVcpus(def)) - 1);
-
- for (i = 0; i < def->os.nBootDevs; i++) {
- switch (def->os.bootDevs[i]) {
- case VIR_DOMAIN_BOOT_FLOPPY:
- bootorder[i] = 'a';
- break;
- default:
- case VIR_DOMAIN_BOOT_DISK:
- bootorder[i] = 'c';
- break;
- case VIR_DOMAIN_BOOT_CDROM:
- bootorder[i] = 'd';
- break;
- case VIR_DOMAIN_BOOT_NET:
- bootorder[i] = 'n';
- break;
- }
- }
- if (def->os.nBootDevs == 0) {
- bootorder[0] = 'c';
- bootorder[1] = '\0';
- } else {
- bootorder[def->os.nBootDevs] = '\0';
- }
- virBufferAsprintf(&buf, "(boot %s)", bootorder);
-
- if (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON)
- virBufferAddLit(&buf, "(acpi 1)");
- if (def->features[VIR_DOMAIN_FEATURE_APIC] == VIR_TRISTATE_SWITCH_ON)
- virBufferAddLit(&buf, "(apic 1)");
- if (def->features[VIR_DOMAIN_FEATURE_PAE] == VIR_TRISTATE_SWITCH_ON)
- virBufferAddLit(&buf, "(pae 1)");
- if (def->features[VIR_DOMAIN_FEATURE_HAP] == VIR_TRISTATE_SWITCH_ON)
- virBufferAddLit(&buf, "(hap 1)");
- if (def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] == VIR_TRISTATE_SWITCH_ON)
- virBufferAddLit(&buf, "(viridian 1)");
-
- virBufferAddLit(&buf, "(usb 1)");
-
- for (i = 0; i < def->ninputs; i++)
- if (xenFormatSxprInput(def->inputs[i], &buf) < 0)
- goto error;
-
- if (def->parallels) {
- virBufferAddLit(&buf, "(parallel ");
- if (xenFormatSxprChr(def->parallels[0], &buf) < 0)
- goto error;
- virBufferAddLit(&buf, ")");
- } else {
- virBufferAddLit(&buf, "(parallel none)");
- }
- if (def->serials) {
- if ((def->nserials > 1) || (def->serials[0]->target.port !=
0)) {
- int maxport = -1, port;
- size_t j = 0;
-
- virBufferAddLit(&buf, "(serial (");
- for (i = 0; i < def->nserials; i++)
- if (def->serials[i]->target.port > maxport)
- maxport = def->serials[i]->target.port;
-
- for (port = 0; port <= maxport; port++) {
- virDomainChrDefPtr chr = NULL;
-
- if (port)
- virBufferAddLit(&buf, " ");
- for (j = 0; j < def->nserials; j++) {
- if (def->serials[j]->target.port == port) {
- chr = def->serials[j];
- break;
- }
- }
- if (chr) {
- if (xenFormatSxprChr(chr, &buf) < 0)
- goto error;
- } else {
- virBufferAddLit(&buf, "none");
- }
- }
- virBufferAddLit(&buf, "))");
- } else {
- virBufferAddLit(&buf, "(serial ");
- if (xenFormatSxprChr(def->serials[0], &buf) < 0)
- goto error;
- virBufferAddLit(&buf, ")");
- }
- } else {
- virBufferAddLit(&buf, "(serial none)");
- }
-
- if (def->sounds) {
- virBufferAddLit(&buf, "(soundhw '");
- if (xenFormatSxprSound(def, &buf) < 0)
- goto error;
- virBufferAddLit(&buf, "')");
- }
- } /* hvm */
-
- /* get the device emulation model */
- if (def->emulator && hvm)
- virBufferEscapeSexpr(&buf, "(device_model '%s')",
def->emulator);
-
- /* look for HPET in order to override the hypervisor/xend default */
- for (i = 0; i < def->clock.ntimers; i++) {
- if (def->clock.timers[i]->name == VIR_DOMAIN_TIMER_NAME_HPET
&&
- def->clock.timers[i]->present != -1) {
- virBufferAsprintf(&buf, "(hpet %d)",
- def->clock.timers[i]->present);
- break;
- }
- }
-
- /* PV graphics for xen <= 3.0.4, or HVM graphics */
- if (hvm) {
- if ((def->ngraphics == 1) &&
- xenFormatSxprGraphicsOld(def->graphics[0], &buf) < 0)
- goto error;
- }
- } else {
- /* PV domains accept kernel cmdline args */
- if (def->os.cmdline) {
- virBufferEscapeSexpr(&buf, "(image (linux (args '%s')",
def->os.cmdline);
- in_image = true;
- }
- } /* os.bootloader */
-
- if (!in_image) {
- if (hvm)
- virBufferAddLit(&buf, "(image (hvm ");
- else
- virBufferAddLit(&buf, "(image (linux ");
- in_image = true;
- }
- if (hvm) {
- /* >=3.1 HV: VARIABLE */
- int rtc_timeoffset;
- switch (def->clock.offset) {
- case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE:
- vmlocaltime = (int)def->clock.data.variable.basis;
- rtc_timeoffset = def->clock.data.variable.adjustment;
- break;
- case VIR_DOMAIN_CLOCK_OFFSET_UTC:
- if (def->clock.data.utc_reset) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("unsupported clock
adjustment='reset'"));
- goto error;
- }
- vmlocaltime = 0;
- rtc_timeoffset = 0;
- break;
- case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
- if (def->clock.data.utc_reset) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("unsupported clock
adjustment='reset'"));
- goto error;
- }
- vmlocaltime = 1;
- rtc_timeoffset = 0;
- break;
- default:
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unsupported clock offset='%s'"),
- virDomainClockOffsetTypeToString(def->clock.offset));
- goto error;
- }
- virBufferAsprintf(&buf, "(rtc_timeoffset %d)", rtc_timeoffset);
- } else {
- /* >=3.1 PV: UTC and LOCALTIME */
- switch (def->clock.offset) {
- case VIR_DOMAIN_CLOCK_OFFSET_UTC:
- vmlocaltime = 0;
- break;
- case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
- vmlocaltime = 1;
- break;
- default:
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unsupported clock offset='%s'"),
- virDomainClockOffsetTypeToString(def->clock.offset));
- goto error;
- }
- } /* !hvm */
- /* default post-XenD-3.1 location: */
- virBufferAsprintf(&buf, "(localtime %d)", vmlocaltime);
-
- if (in_image) {
- /* closes (image(hvm|linux */
- virBufferAddLit(&buf, "))");
- in_image = false;
- }
- /* pre-XenD-3.1 and compatibility location */
- virBufferAsprintf(&buf, "(localtime %d)", vmlocaltime);
-
-
- for (i = 0; i < def->ndisks; i++)
- if (xenFormatSxprDisk(def->disks[i], &buf, hvm, 0) < 0)
- goto error;
-
- for (i = 0; i < def->nnets; i++)
- if (xenFormatSxprNet(conn, def->nets[i], &buf, hvm, 0) < 0)
- goto error;
-
- if (xenFormatSxprAllPCI(def, &buf) < 0)
- goto error;
-
- /* New style PV graphics config xen >= 3.0.4 */
- if (!hvm) {
- if ((def->ngraphics == 1) &&
- xenFormatSxprGraphicsNew(def->graphics[0], &buf) < 0)
- goto error;
- }
-
- virBufferAddLit(&buf, ")"); /* closes (vm */
-
- if (virBufferCheckError(&buf) < 0)
- goto error;
-
- bufout = virBufferContentAndReset(&buf);
- VIR_DEBUG("Formatted sexpr: \n%s", bufout);
- return bufout;
-
- error:
- virBufferFreeAndReset(&buf);
- return NULL;
-}
diff --git a/src/xenconfig/xen_sxpr.h b/src/xenconfig/xen_sxpr.h
index 019657380c..93af981544 100644
--- a/src/xenconfig/xen_sxpr.h
+++ b/src/xenconfig/xen_sxpr.h
@@ -50,17 +50,5 @@ virDomainChrDefPtr xenParseSxprChar(const char *value, const char
*tty);
int xenParseSxprVifRate(const char *rate, unsigned long long *kbytes_per_sec);
-int xenFormatSxprDisk(virDomainDiskDefPtr def, virBufferPtr buf, int hvm,
- int isAttach);
-
-int xenFormatSxprNet(virConnectPtr conn,
- virDomainNetDefPtr def, virBufferPtr buf, int hvm,
- int isAttach);
-
-int xenFormatSxprOnePCI(virDomainHostdevDefPtr def, virBufferPtr buf,
- int detach);
-
int xenFormatSxprChr(virDomainChrDefPtr def, virBufferPtr buf);
int xenFormatSxprSound(virDomainDefPtr def, virBufferPtr buf);
-
-char * xenFormatSxpr(virConnectPtr conn, virDomainDefPtr def);
--
2.21.0