Re: virtio console: name=foo is not supported

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

 



(2011/12/13 13:02), MATSUDA, Daiki wrote:
(2011/12/12 22:58), Daniel P. Berrange wrote:
On Mon, Dec 12, 2011 at 10:18:23AM +0900, MATSUDA, Daiki wrote:

In addition, the QEMU guest agent requires specified socket. Virt IO
Console, too. But unfortunately libvirt does not support to xml tags
to give socket name options to QEMU for the QEMU guest agent and
Virt IO Console.

Err, yes we do.

<channel type='unix'>
<source mode='bind' path='/var/lib/libvirt/qemu/f16x86_64.agent'/>
<target type='virtio' name='org.qemu.guest_agent.0'/>
</channel>

Yes, I confirmed that it can create the socket for guest agent and
communicate to guest.

Or for the console

<console type='unix'>
<source mode='bind'
path='/var/lib/libvirt/qemu/f16x86_64.console'/>
<target type='virtio'/>
</channel>

though you really want to use type=pty for consoles, so that
'virsh console'
works correctly.

Daniel

But It is not enough. Because I use the socket for VirtIO console,
i.e. gives the option '-device virtconsole,chardev=...,name=foo' for
qemu.

And I read the source code, but found funny...
In src/conf/domain_conf.h, struct _virDomainChrDef is
struct _virDomainChrDef {
...
union {
int port; /* parallel, serial, console */
virSocketAddrPtr addr; /* guestfwd */
char *name; /* virtio */
} target;
...
It is written that virtio must use char *name.

But in docs/schemas/domaincommon.rng and others, VirtIO Console use
only int port.

Thoug I do not understand that which should be used, I attaches the
patch for using *name.

Neither is really relevant for virtio-console, it just provides one or
more
interactive console for admins.

The name is only relevant when coming to create virtio serial channels
for non-interactive use. eg the<channel> elements.

Daniel

My simple requirement is to give qemu the option such as
-device virtio-serial \
-chardev socket,path=/tmp/foo,server,nowait,id=foo \
-device virtconsole,chardev=foo,name=org.fedoraproject.console.foo
(e.g. http://fedoraproject.org/wiki/Features/VirtioSerial it has a
little mistake not virtioconsole but virtconsole.)

But current libvirt source code does not accept name=... with
virtconsole. Because 'virtconsole' is only added on
qemuBuildVirtioSerialPortDevStr() in src/qemu/qemu_command.c when
dev->deviceType is VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE and 'name=' is
only added on some function when dev->deviceType is
VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL.

Similarly it is impossible to use <channel> instead of <console> for
virtconsole because deviceType is set as
VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL.


So, if it is possible to take 2 options port and name for <console>
virtio, could you modify from union to struct on struct _vifDomainChrDef
in src/conf/domain_conf.h ?

MATSUDA Daiki

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



I have modified the patch to change from union to struct for struct _vifDomainChrDef.
At least, port and name can exist togethter.

MATSUDA Daiki

diff -uNrp libvirt-0.9.8.orig/docs/schemas/domaincommon.rng libvirt-0.9.8/docs/schemas/domaincommon.rng --- libvirt-0.9.8.orig/docs/schemas/domaincommon.rng 2011-12-08 11:29:49.000000000 +0900 +++ libvirt-0.9.8/docs/schemas/domaincommon.rng 2011-12-15 08:51:27.829971955 +0900
@@ -1814,6 +1814,9 @@
         <optional>
           <attribute name="port"/>
         </optional>
+        <optional>
+          <attribute name="name"/>
+        </optional>
       </interleave>
     </element>
   </define>
diff -uNrp libvirt-0.9.8.orig/src/conf/domain_conf.c libvirt-0.9.8/src/conf/domain_conf.c --- libvirt-0.9.8.orig/src/conf/domain_conf.c 2011-12-08 11:29:49.000000000 +0900
+++ libvirt-0.9.8/src/conf/domain_conf.c	2011-12-15 08:51:27.839971932 +0900
@@ -1156,22 +1156,10 @@ void virDomainChrDefFree(virDomainChrDef
     if (!def)
         return;

-    switch (def->deviceType) {
-    case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL:
-        switch (def->targetType) {
-        case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD:
-            VIR_FREE(def->target.addr);
-            break;
-
-        case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO:
-            VIR_FREE(def->target.name);
-            break;
-        }
-        break;
-
-    default:
-        break;
-    }
+    if (def->target.addr)
+        VIR_FREE(def->target.addr);
+    if (def->target.name)
+        VIR_FREE(def->target.name);

     virDomainChrSourceDefClear(&def->source);
     virDomainDeviceInfoClear(&def->info);
@@ -3969,6 +3957,8 @@ virDomainChrDefParseTargetXML(virCapsPtr
         break;

     default:
+        def->target.name = virXMLPropString(cur, "name");
+
         portStr = virXMLPropString(cur, "port");
         if (portStr == NULL) {
             /* Set to negative value to indicate we should set it later */
@@ -3983,6 +3973,7 @@ virDomainChrDefParseTargetXML(virCapsPtr
             goto error;
         }
         def->target.port = port;
+
         break;
     }

@@ -10406,10 +10397,14 @@ virDomainChrDefFormat(virBufferPtr buf,

     case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
         virBufferAsprintf(buf,
-                          "      <target type='%s' port='%d'/>\n",
+                          "      <target type='%s'",
                           virDomainChrTargetTypeToString(def->deviceType,
-                                                         def->targetType),
-                          def->target.port);
+                                                         def->targetType));
+        if (def->target.port != -1)
+            virBufferAsprintf(buf, " port='%d'", def->target.port);
+        if (def->target.name)
+            virBufferAsprintf(buf, " name='%s'", def->target.name);
+        virBufferAsprintf(buf, "/>\n");
         break;

     default:
diff -uNrp libvirt-0.9.8.orig/src/conf/domain_conf.h libvirt-0.9.8/src/conf/domain_conf.h --- libvirt-0.9.8.orig/src/conf/domain_conf.h 2011-12-08 11:29:49.000000000 +0900
+++ libvirt-0.9.8/src/conf/domain_conf.h	2011-12-15 08:51:27.830961800 +0900
@@ -693,10 +693,10 @@ typedef virDomainChrDef *virDomainChrDef
 struct _virDomainChrDef {
     int deviceType;
     int targetType;
-    union {
-        int port; /* parallel, serial, console */
+    struct {
+        int port; /* parallel, serial, console, virtio console */
         virSocketAddrPtr addr; /* guestfwd */
-        char *name; /* virtio */
+        char *name; /* virtio, virtio console */
     } target;

     virDomainChrSourceDef source;
diff -uNrp libvirt-0.9.8.orig/src/qemu/qemu_command.c libvirt-0.9.8/src/qemu/qemu_command.c --- libvirt-0.9.8.orig/src/qemu/qemu_command.c 2011-12-02 12:59:50.000000000 +0900 +++ libvirt-0.9.8/src/qemu/qemu_command.c 2011-12-15 08:51:27.832971775 +0900
@@ -3061,8 +3061,7 @@ qemuBuildVirtioSerialPortDevStr(virDomai
           qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPICEVMC))) {
         virBufferAsprintf(&buf, ",chardev=char%s,id=%s",
                           dev->info.alias, dev->info.alias);
-        if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
-            dev->target.name) {
+        if (dev->target.name) {
             virBufferAsprintf(&buf, ",name=%s", dev->target.name);
         }
     } else {
diff -uNrp libvirt-0.9.8.orig/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many-mix.args libvirt-0.9.8/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many-mix.args --- libvirt-0.9.8.orig/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many-mix.args 1970-01-01 09:00:00.000000000 +0900 +++ libvirt-0.9.8/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many-mix.args 2011-12-15 08:51:27.842971912 +0900
@@ -0,0 +1,12 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
+pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -chardev \
+socket,id=charmonitor,path=/tmp/test-monitor,server,nowait -mon \
+chardev=charmonitor,id=monitor,mode=readline -no-acpi -boot c -device \
+virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x3 -hda \
+/dev/HostVG/QEMUGuest1 -chardev pty,id=charserial0 \
+-device isa-serial,chardev=charserial0,id=serial0 -chardev pty,id=charconsole1 \
+-device virtconsole,chardev=charconsole1,id=console1,name=bar1 -chardev \
+pty,id=charconsole2 -device virtconsole,chardev=charconsole2,id=console2,name=foo2 \
+-chardev pty,id=charconsole3 -device virtconsole,chardev=charconsole3,\
+id=console3,name=bar3 -usb -device virtio-balloon-pci,id=balloon0,\
+bus=pci.0,addr=0x4
diff -uNrp libvirt-0.9.8.orig/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many-mix.xml libvirt-0.9.8/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many-mix.xml --- libvirt-0.9.8.orig/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many-mix.xml 1970-01-01 09:00:00.000000000 +0900 +++ libvirt-0.9.8/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many-mix.xml 2011-12-15 08:51:27.842971912 +0900
@@ -0,0 +1,41 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory>219100</memory>
+  <currentMemory>219100</currentMemory>
+  <vcpu cpuset='1-4,8-20,525'>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'/>
+    <controller type='virtio-serial' index='0'/>
+    <serial type='pty'>
+      <target port='0'/>
+    </serial>
+    <console type='pty'>
+      <target type='serial' port='0' name='foo0'/>
+    </console>
+    <console type='pty'>
+      <target type='virtio' name='bar1'/>
+    </console>
+    <console type='pty'>
+      <target type='virtio' name='foo2' port='2'/>
+    </console>
+    <console type='pty'>
+      <target type='virtio' port='3' name='bar3'/>
+    </console>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff -uNrp libvirt-0.9.8.orig/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many-name.args libvirt-0.9.8/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many-name.args --- libvirt-0.9.8.orig/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many-name.args 1970-01-01 09:00:00.000000000 +0900 +++ libvirt-0.9.8/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many-name.args 2011-12-15 08:51:27.834971875 +0900
@@ -0,0 +1,12 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
+pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -chardev \
+socket,id=charmonitor,path=/tmp/test-monitor,server,nowait -mon \
+chardev=charmonitor,id=monitor,mode=readline -no-acpi -boot c -device \
+virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x3 -hda \
+/dev/HostVG/QEMUGuest1 -chardev pty,id=charserial0 \
+-device isa-serial,chardev=charserial0,id=serial0 -chardev pty,id=charconsole1 \
+-device virtconsole,chardev=charconsole1,id=console1,name=bar1 -chardev \
+pty,id=charconsole2 -device virtconsole,chardev=charconsole2,id=console2,name=foo2 \
+-chardev pty,id=charconsole3 -device virtconsole,chardev=charconsole3,\
+id=console3,name=bar3 -usb -device virtio-balloon-pci,id=balloon0,\
+bus=pci.0,addr=0x4
diff -uNrp libvirt-0.9.8.orig/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many-name.xml libvirt-0.9.8/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many-name.xml --- libvirt-0.9.8.orig/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many-name.xml 1970-01-01 09:00:00.000000000 +0900 +++ libvirt-0.9.8/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many-name.xml 2011-12-15 08:51:27.834971875 +0900
@@ -0,0 +1,41 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory>219100</memory>
+  <currentMemory>219100</currentMemory>
+  <vcpu cpuset='1-4,8-20,525'>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'/>
+    <controller type='virtio-serial' index='0'/>
+    <serial type='pty'>
+      <target port='0'/>
+    </serial>
+    <console type='pty'>
+      <target type='serial' name='foo0'/>
+    </console>
+    <console type='pty'>
+      <target type='virtio' name='bar1'/>
+    </console>
+    <console type='pty'>
+      <target type='virtio' name='foo2'/>
+    </console>
+    <console type='pty'>
+      <target type='virtio' name='bar3'/>
+    </console>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff -uNrp libvirt-0.9.8.orig/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-mix.args libvirt-0.9.8/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-mix.args --- libvirt-0.9.8.orig/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-mix.args 1970-01-01 09:00:00.000000000 +0900 +++ libvirt-0.9.8/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-mix.args 2011-12-15 08:51:27.841971785 +0900
@@ -0,0 +1,8 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
+pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -chardev \
+socket,id=charmonitor,path=/tmp/test-monitor,server,nowait -mon \
+chardev=charmonitor,id=monitor,mode=readline -no-acpi -boot c -device \
+virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x3 -hda \
+/dev/HostVG/QEMUGuest1 -chardev pty,id=charconsole0 -device virtconsole,\
+chardev=charconsole0,id=console0,name=foo -usb -device virtio-balloon-pci,id=balloon0,\
+bus=pci.0,addr=0x4
diff -uNrp libvirt-0.9.8.orig/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-mix.xml libvirt-0.9.8/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-mix.xml --- libvirt-0.9.8.orig/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-mix.xml 1970-01-01 09:00:00.000000000 +0900 +++ libvirt-0.9.8/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-mix.xml 2011-12-15 08:51:27.841971785 +0900
@@ -0,0 +1,27 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory>219100</memory>
+  <currentMemory>219100</currentMemory>
+  <vcpu cpuset='1-4,8-20,525'>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'/>
+    <console type='pty'>
+      <target type='virtio' port='0' name='foo'/>
+    </console>
+  </devices>
+</domain>
diff -uNrp libvirt-0.9.8.orig/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-name.args libvirt-0.9.8/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-name.args --- libvirt-0.9.8.orig/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-name.args 1970-01-01 09:00:00.000000000 +0900 +++ libvirt-0.9.8/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-name.args 2011-12-15 08:51:27.841971785 +0900
@@ -0,0 +1,8 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
+pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -chardev \
+socket,id=charmonitor,path=/tmp/test-monitor,server,nowait -mon \
+chardev=charmonitor,id=monitor,mode=readline -no-acpi -boot c -device \
+virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x3 -hda \
+/dev/HostVG/QEMUGuest1 -chardev pty,id=charconsole0 -device virtconsole,\
+chardev=charconsole0,id=console0,name=foo -usb -device virtio-balloon-pci,id=balloon0,\
+bus=pci.0,addr=0x4
diff -uNrp libvirt-0.9.8.orig/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-name.xml libvirt-0.9.8/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-name.xml --- libvirt-0.9.8.orig/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-name.xml 1970-01-01 09:00:00.000000000 +0900 +++ libvirt-0.9.8/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-name.xml 2011-12-15 08:51:27.841971785 +0900
@@ -0,0 +1,27 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory>219100</memory>
+  <currentMemory>219100</currentMemory>
+  <vcpu cpuset='1-4,8-20,525'>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'/>
+    <console type='pty'>
+      <target type='virtio' name='foo'/>
+    </console>
+  </devices>
+</domain>
diff -uNrp libvirt-0.9.8.orig/tests/qemuxml2argvtest.c libvirt-0.9.8/tests/qemuxml2argvtest.c --- libvirt-0.9.8.orig/tests/qemuxml2argvtest.c 2011-12-02 12:59:56.000000000 +0900 +++ libvirt-0.9.8/tests/qemuxml2argvtest.c 2011-12-15 08:51:27.843971916 +0900
@@ -539,6 +539,14 @@ mymain(void)
             QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
     DO_TEST("console-virtio-many", false,
             QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
+    DO_TEST("console-virtio-name", false,
+            QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
+    DO_TEST("console-virtio-many-name", false,
+            QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
+    DO_TEST("console-virtio-mix", false,
+            QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
+    DO_TEST("console-virtio-many-mix", false,
+            QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
     DO_TEST("channel-spicevmc", false,
             QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC);

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