[libvirt] [PATCH] tests: add qemu/argv test for vnc-passwd feature [was: Support VNC password for QEMU guests

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

 



"Daniel P. Berrange" <berrange@xxxxxxxxxx> wrote:
> This patch adds support for using the monitor interface to set the VNC
> password
>
>   (qemu) change vnc password
>   Password: ********
>
> A minor tricky thing is that we can't just send the command and password
> all in one go, we must wait for the 'Password' prompt before sending the
> password.
>
> When doing this I noticed that virsh dumpxml has no way to request a
> secure XML dump (required to see the password element), nor did the
> virsh edit command set the SECURE or INACTIVE flags when changing
> the XML.
>
>  qemu_conf.c   |   45 ++++++++++++-----------
>  qemu_driver.c |  112 ++++++++++++++++++++++++++++++++++++++++++++--------------

As you suggested, here's a test of the command-line/xml-processing part:

A couple minor things I'm going to change eventually:

1) The name of every file in the qemuxml2argvdata/ directory
  starts with qemuxml2argv.  I'm going to remove those suffixes
  and adjust the few callers.

2) Currently, each test case (pair of .args, .xml files) is checked
in separately, giving no clue as to how similar the inputs of one
test may be to another.  Seeing such relationships would make
it easier to add new tests.

For example in this case, I've just added `, passwd="123456"'
to the <graphics.../> line in the existing vnc-passwd.xml file:

    $ sed '/<graphics/s,/, passwd="123456"/,' qemuxml2argv-graphics-vnc.xml \
      | diff -u - qemuxml2argv-vnc-passwd.xml

    -    <graphics type='vnc' ... listen='127.0.0.1'/>
    +    <graphics type='vnc' ... listen='127.0.0.1' passwd="123456"/>

and appended ",password" to its .args file:

    $ sed 's/:3$/:3,password/' qemuxml2argv-graphics-vnc.args \
      | diff -u - qemuxml2argv-vnc-passwd.args

    -LC_ALL=C ... -vnc 127.0.0.1:3
    +LC_ALL=C ... -vnc 127.0.0.1:3,password


>From ab770e0becc5b13cbd59f0f1219bb719f29e20d5 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@xxxxxxxxxx>
Date: Wed, 21 Jan 2009 17:22:59 +0100
Subject: [PATCH] tests: add an qemu/argv test for the new vnc-passwd feature

* tests/qemuxml2argvtest.c (mymain): Run the new test.
* tests/qemuxml2argvdata/qemuxml2argv-vnc-passwd.xml: New file.
* tests/qemuxml2argvdata/qemuxml2argv-vnc-passwd.args: Likewise.
---
 .../qemuxml2argvdata/qemuxml2argv-vnc-passwd.args  |    1 +
 tests/qemuxml2argvdata/qemuxml2argv-vnc-passwd.xml |   24 ++++++++++++++++++++
 tests/qemuxml2argvtest.c                           |    2 +
 3 files changed, 27 insertions(+), 0 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-vnc-passwd.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-vnc-passwd.xml

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-vnc-passwd.args b/tests/qemuxml2argvdata/qemuxml2argv-vnc-passwd.args
new file mode 100644
index 0000000..30cc17b
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-vnc-passwd.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -monitor pty -pidfile /nowhere/QEMUGuest1.pid -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -vnc 127.0.0.1:3,password
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-vnc-passwd.xml b/tests/qemuxml2argvdata/qemuxml2argv-vnc-passwd.xml
new file mode 100644
index 0000000..da6ecf3
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-vnc-passwd.xml
@@ -0,0 +1,24 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory>219200</memory>
+  <currentMemory>219200</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'/>
+    </disk>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='5903' autoport='no' listen='127.0.0.1' passwd="123456"/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 17684fd..5607ea0 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -226,6 +226,8 @@ mymain(int argc, char **argv)

     DO_TEST("hostdev-pci-address", 0);

+    DO_TEST("vnc-passwd", 0);
+
     virCapabilitiesFree(driver.caps);

     return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
--
1.6.1.347.g0238

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