goto cleanup;
}
+/* Create a new character device definition and set
+ * default port.
+ */
+virDomainChrDefPtr
+virDomainChrDefNew(void) {
+ virDomainChrDefPtr def = NULL;
+
+ if (VIR_ALLOC(def) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ def->target.port = -1;
+ return def;
+}
+
/* Parse the XML definition for a character device
* @param node XML nodeset to parse for net definition
*
virDomainChrDefPtr def;
int remaining;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (!(def = virDomainChrDefNew()))
return NULL;
- }
type = virXMLPropString(node, "type");
if (type == NULL) {
/* Returns 1 if the object was freed, 0 if more refs exist */
int virDomainObjUnref(virDomainObjPtr vm) ATTRIBUTE_RETURN_CHECK;
+virDomainChrDefPtr virDomainChrDefNew(void);
+
/* live == true means def describes an active domain (being migrated or
* restored) as opposed to a new persistent configuration of the domain */
virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
virDomainChrConsoleTargetTypeToString;
virDomainChrDefForeach;
virDomainChrDefFree;
+virDomainChrDefNew;
virDomainChrSourceDefFree;
virDomainChrSpicevmcTypeFromString;
virDomainChrSpicevmcTypeToString;
#include "c-ctype.h"
#include "domain_nwfilter.h"
#include "qemu_audit.h"
+#include "domain_conf.h"
#include <sys/utsname.h>
#include <sys/stat.h>
{
virDomainChrDefPtr def;
- if (VIR_ALLOC(def) < 0)
- goto no_memory;
+ if (!(def = virDomainChrDefNew()))
+ goto error;
if (STREQ(val, "null")) {
def->source.type = VIR_DOMAIN_CHR_TYPE_NULL;
char *tmp;
virDomainChrDefPtr def;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (!(def = virDomainChrDefNew()))
return NULL;
- }
prefix = value;
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
+ chr->target.port = 0;
def->serials[def->nserials++] = chr;
}
}
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
+ chr->target.port = 0;
def->parallels[def->nparallels++] = chr;
}
} else {
if (!(def->console = xenParseSxprChar("pty", tty)))
goto error;
def->console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
+ def->console->target.port = 0;
def->console->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
}
VIR_FREE(tty);
#include "xenxs_private.h"
#include "xen_xm.h"
#include "xen_sxpr.h"
+#include "domain_conf.h"
/* Convenience method to grab a int from the config file object */
static int xenXMConfigGetBool(virConfPtr conf,
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
+ chr->target.port = 0;
def->parallels[0] = chr;
def->nparallels++;
chr = NULL;
continue;
}
- if (VIR_ALLOC(chr) < 0)
- goto no_memory;
+ if (!(chr = virDomainChrDefNew()))
+ goto cleanup;
if (!(chr = xenParseSxprChar(port, NULL)))
goto cleanup;
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
+ chr->target.port = 0;
def->serials[0] = chr;
def->nserials++;
}
if (!(def->console = xenParseSxprChar("pty", NULL)))
goto cleanup;
def->console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
+ def->console->target.port = 0;
def->console->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
}
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219100</memory>
+ <currentMemory>219100</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <serial type='pty'/>
+ <serial type='null'/>
+ <serial type='stdio'/>
+ <console type='pty'>
+ <target port='0'/>
+ </console>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219100</memory>
+ <currentMemory>219100</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <serial type='null'>
+ <target port='1'/>
+ </serial>
+ <serial type='stdio'>
+ <target port='2'/>
+ </serial>
+ <console type='pty'>
+ <target type='serial' port='0'/>
+ </console>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
DO_TEST_DIFFERENT("console-compat-auto");
DO_TEST_DIFFERENT("disk-scsi-device-auto");
DO_TEST_DIFFERENT("console-virtio");
+ DO_TEST_DIFFERENT("serial-target-port-auto");
virCapabilitiesFree(driver.caps);