提交 e3af6437 编写于 作者: D Daniel P. Berrange

Fixed handling of -nographics. Added VNC listen support

上级 1d4d4f3b
Tue Jul 24 10:29:11 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/qemu_conf.c, src/qemu_conf.h: Added support for the VNC
'listen' parameter in XML. Move -nographics flag to start of
command line to avoid issues with QEMU default monitor settings.
* tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c: Re-enable
VNC & SDL tests now they are working correctly
* tests/qemudxml2argvdata/*.args: Move -nographics arg to new
location due to qemu_conf.c changes
Tue Jul 24 10:24:11 EST 2007 Daniel P. Berrange <berrange@redhat.com> Tue Jul 24 10:24:11 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/qemu_driver.c: Fixed crash when cleaning up after failed * src/qemu_driver.c: Fixed crash when cleaning up after failed
......
...@@ -1197,14 +1197,23 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn, ...@@ -1197,14 +1197,23 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
def->graphicsType = QEMUD_GRAPHICS_NONE; def->graphicsType = QEMUD_GRAPHICS_NONE;
} else if ((prop = xmlGetProp(obj->nodesetval->nodeTab[0], BAD_CAST "type"))) { } else if ((prop = xmlGetProp(obj->nodesetval->nodeTab[0], BAD_CAST "type"))) {
if (!strcmp((char *)prop, "vnc")) { if (!strcmp((char *)prop, "vnc")) {
xmlChar *vncport, *vnclisten;
def->graphicsType = QEMUD_GRAPHICS_VNC; def->graphicsType = QEMUD_GRAPHICS_VNC;
prop = xmlGetProp(obj->nodesetval->nodeTab[0], BAD_CAST "port"); vncport = xmlGetProp(obj->nodesetval->nodeTab[0], BAD_CAST "port");
if (prop) { if (vncport) {
conv = NULL; conv = NULL;
def->vncPort = strtoll((const char*)prop, &conv, 10); def->vncPort = strtoll((const char*)vncport, &conv, 10);
} else { } else {
def->vncPort = -1; def->vncPort = -1;
} }
vnclisten = xmlGetProp(obj->nodesetval->nodeTab[0], BAD_CAST "listen");
if (vnclisten && *vnclisten)
strncpy(def->vncListen, (char *)vnclisten, BR_INET_ADDR_MAXLEN-1);
else
strcpy(def->vncListen, "127.0.0.1");
def->vncListen[BR_INET_ADDR_MAXLEN-1] = '\0';
xmlFree(vncport);
xmlFree(vnclisten);
} else if (!strcmp((char *)prop, "sdl")) { } else if (!strcmp((char *)prop, "sdl")) {
def->graphicsType = QEMUD_GRAPHICS_SDL; def->graphicsType = QEMUD_GRAPHICS_SDL;
} else { } else {
...@@ -1511,6 +1520,18 @@ int qemudBuildCommandLine(virConnectPtr conn, ...@@ -1511,6 +1520,18 @@ int qemudBuildCommandLine(virConnectPtr conn,
if (!((*argv)[++n] = strdup(vcpus))) if (!((*argv)[++n] = strdup(vcpus)))
goto no_memory; goto no_memory;
/*
* NB, -nographic *MUST* come before any serial, or monitor
* or parallel port flags due to QEMU craziness, where it
* decides to change the serial port & monitor to be on stdout
* if you ask for nographic. So we have to make sure we override
* these defaults ourselves...
*/
if (vm->def->graphicsType == QEMUD_GRAPHICS_NONE) {
if (!((*argv)[++n] = strdup("-nographic")))
goto no_memory;
}
if (!((*argv)[++n] = strdup("-monitor"))) if (!((*argv)[++n] = strdup("-monitor")))
goto no_memory; goto no_memory;
if (!((*argv)[++n] = strdup("pty"))) if (!((*argv)[++n] = strdup("pty")))
...@@ -1700,22 +1721,24 @@ int qemudBuildCommandLine(virConnectPtr conn, ...@@ -1700,22 +1721,24 @@ int qemudBuildCommandLine(virConnectPtr conn,
} }
if (vm->def->graphicsType == QEMUD_GRAPHICS_VNC) { if (vm->def->graphicsType == QEMUD_GRAPHICS_VNC) {
char port[10]; char vncdisplay[BR_INET_ADDR_MAXLEN+20];
int ret; int ret;
ret = snprintf(port, sizeof(port), if (driver->qemuCmdFlags & QEMUD_CMD_FLAG_VNC_COLON)
((driver->qemuCmdFlags & QEMUD_CMD_FLAG_VNC_COLON) ? ret = snprintf(vncdisplay, sizeof(vncdisplay), "%s:%d",
":%d" : "%d"), vm->def->vncListen,
vm->def->vncActivePort - 5900); vm->def->vncActivePort - 5900);
if (ret < 0 || ret >= (int)sizeof(port)) else
ret = snprintf(vncdisplay, sizeof(vncdisplay), "%d",
vm->def->vncActivePort - 5900);
if (ret < 0 || ret >= (int)sizeof(vncdisplay))
goto error; goto error;
if (!((*argv)[++n] = strdup("-vnc"))) if (!((*argv)[++n] = strdup("-vnc")))
goto no_memory; goto no_memory;
if (!((*argv)[++n] = strdup(port))) if (!((*argv)[++n] = strdup(vncdisplay)))
goto no_memory; goto no_memory;
} else if (vm->def->graphicsType == QEMUD_GRAPHICS_NONE) { } else if (vm->def->graphicsType == QEMUD_GRAPHICS_NONE) {
if (!((*argv)[++n] = strdup("-nographic"))) /* Nada - we added -nographic earlier in this function */
goto no_memory;
} else { } else {
/* SDL is the default. no args needed */ /* SDL is the default. no args needed */
} }
...@@ -2931,6 +2954,11 @@ char *qemudGenerateXML(virConnectPtr conn, ...@@ -2931,6 +2954,11 @@ char *qemudGenerateXML(virConnectPtr conn,
qemudIsActiveVM(vm) && live ? def->vncActivePort : def->vncPort) < 0) qemudIsActiveVM(vm) && live ? def->vncActivePort : def->vncPort) < 0)
goto no_memory; goto no_memory;
if (def->vncListen[0] &&
virBufferVSprintf(buf, " listen='%s'",
def->vncListen) < 0)
goto no_memory;
if (virBufferAdd(buf, "/>\n", -1) < 0) if (virBufferAdd(buf, "/>\n", -1) < 0)
goto no_memory; goto no_memory;
break; break;
......
...@@ -186,6 +186,7 @@ struct qemud_vm_def { ...@@ -186,6 +186,7 @@ struct qemud_vm_def {
int graphicsType; int graphicsType;
int vncPort; int vncPort;
int vncActivePort; int vncActivePort;
char vncListen[BR_INET_ADDR_MAXLEN];
int ndisks; int ndisks;
struct qemud_vm_disk_def *disks; struct qemud_vm_disk_def *disks;
......
/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot d -cdrom /dev/cdrom -net none -usb -nographic /usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot d -cdrom /dev/cdrom -net none -usb
\ No newline at end of file \ No newline at end of file
/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot a -hda /dev/HostVG/QEMUGuest1 -fda /tmp/firmware.img -net none -usb -nographic /usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot a -hda /dev/HostVG/QEMUGuest1 -fda /tmp/firmware.img -net none -usb
\ No newline at end of file \ No newline at end of file
/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot n -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic /usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot n -hda /dev/HostVG/QEMUGuest1 -net none -usb
\ No newline at end of file \ No newline at end of file
/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -localtime -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic /usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -localtime -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb
\ No newline at end of file \ No newline at end of file
/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic /usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb
\ No newline at end of file \ No newline at end of file
/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -cdrom /root/boot.iso -net none -usb -nographic /usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -cdrom /root/boot.iso -net none -usb
\ No newline at end of file \ No newline at end of file
/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -fda /dev/fd0 -fdb /tmp/firmware.img -net none -usb -nographic /usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -fda /dev/fd0 -fdb /tmp/firmware.img -net none -usb
\ No newline at end of file \ No newline at end of file
/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -hdb /dev/HostVG/QEMUGuest2 -hdc /tmp/data.img -hdd /tmp/logs.img -net none -usb -nographic /usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -hdb /dev/HostVG/QEMUGuest2 -hdc /tmp/data.img -hdd /tmp/logs.img -net none -usb
\ No newline at end of file \ No newline at end of file
/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -sdl /usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb
\ No newline at end of file \ No newline at end of file
/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -usbdevice mouse -nographic /usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -usbdevice mouse
\ No newline at end of file \ No newline at end of file
/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -usbdevice tablet -nographic /usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -usbdevice tablet
\ No newline at end of file \ No newline at end of file
/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic /usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb
\ No newline at end of file \ No newline at end of file
/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic /usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb
\ No newline at end of file \ No newline at end of file
/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-reboot -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic /usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-reboot -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb
\ No newline at end of file \ No newline at end of file
/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net nic,macaddr=00:11:22:33:44:55,vlan=0 -net user,vlan=0 -usb -nographic /usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net nic,macaddr=00:11:22:33:44:55,vlan=0 -net user,vlan=0 -usb
\ No newline at end of file \ No newline at end of file
...@@ -146,11 +146,11 @@ main(int argc, char **argv) ...@@ -146,11 +146,11 @@ main(int argc, char **argv)
1, testCompareXMLToArgvHelper, "disk-many") < 0) 1, testCompareXMLToArgvHelper, "disk-many") < 0)
ret = -1; ret = -1;
if (0 && virtTestRun("QEMU XML-2-ARGV Graphics VNC", if (virtTestRun("QEMU XML-2-ARGV Graphics VNC",
1, testCompareXMLToArgvHelper, "graphics-vnc") < 0) 1, testCompareXMLToArgvHelper, "graphics-vnc") < 0)
ret = -1; ret = -1;
if (0 && virtTestRun("QEMU XML-2-ARGV Graphics SDL", if (virtTestRun("QEMU XML-2-ARGV Graphics SDL",
1, testCompareXMLToArgvHelper, "graphics-sdl") < 0) 1, testCompareXMLToArgvHelper, "graphics-sdl") < 0)
ret = -1; ret = -1;
......
...@@ -111,7 +111,7 @@ main(int argc, char **argv) ...@@ -111,7 +111,7 @@ main(int argc, char **argv)
1, testCompareXMLToXMLHelper, "disk-many") < 0) 1, testCompareXMLToXMLHelper, "disk-many") < 0)
ret = -1; ret = -1;
if (0 && virtTestRun("QEMU XML-2-ARGV Graphics VNC", if (virtTestRun("QEMU XML-2-ARGV Graphics VNC",
1, testCompareXMLToXMLHelper, "graphics-vnc") < 0) 1, testCompareXMLToXMLHelper, "graphics-vnc") < 0)
ret = -1; ret = -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册