[Libvir] RFC: Supporting serial & parallel ports for QEMU (and improving Xen)
by Daniel P. Berrange
One user's feature request for our QEMU driver is to support serial ports.
Easy you might think... you'd be wrong :-)
On Xen we have very simple approach. When creating a guest simply add
<console/>
And it'll cause a serial port to be setup with an autoallocated pty, so
you get back
<console pty='/dev/pts/5'/>
In retrospect calling it 'console' was dumb, but hey we're stuck with that
now and its only a tiny naming issue so I don't mind really.
We can do the same thing with QEMU quite easily. QEMU, however, supports
many many many more ways to hooking up the serial port to Dom0. Indeed
so does Xen fullyvirt, but we don't expose this ability. Parallel ports
have identical config syntax to serial ports so we might as well deal
with both at once.
So, here's a stripped down version of the QEMU docs:
[quote http://fabrice.bellard.free.fr/qemu/qemu-doc.html#SEC10]
`-serial dev'
Redirect the virtual serial port to host character device dev. The
default device is vc in graphical mode and stdio in non graphical
mode. This option can be used several times to simulate up to 4
serials ports. Use -serial none to disable all serial ports.
Available character devices are:
vc
Virtual console
pty
[Linux only] Pseudo TTY (a new PTY is automatically allocated)
none
No device is allocated.
null
void device
/dev/XXX
[Linux only] Use host tty, e.g. `/dev/ttyS0'. The host serial port
parameters are set according to the emulated ones.
/dev/parportN
[Linux only, parallel port only] Use host parallel port N. Currently
only SPP parallel port features can be used.
file:filename
Write output to filename. No character can be read.
stdio
[Unix only] standard input/output
pipe:filename
name pipe filename
COMn
[Windows only] Use host serial port n
udp:[remote_host]:remote_port[@[src_ip]:src_port]
This implements UDP Net Console.
tcp:[host]:port[,server][,nowait][,nodelay]
The TCP Net Console has two modes of operation.
telnet:host:port[,server][,nowait][,nodelay]
The telnet protocol is used instead of raw tcp sockets.
unix:path[,server][,nowait]
A unix domain socket is used instead of a tcp socket.
[/quote]
I don't see any reason to not support all/most of these options. The things
I don't like here is that /dev/XXX, vs /dev/parportN, vs COMn differences
for connecting guest <-> host passthrough of the devices. I figure it could
be simpler if it was just represented as 'n' and we'd translate that to
be /dev/ttyS[n] or /dev/parport[n] or COM[n] as needed.
The question as ever is how to represent this in XML. For serial ports we'll
stick with '<console>', while parallel ports we might as well use a better
named '<parallel>'. Next up, I think should use a 'type' attribute on this
element to determine the main way ot connecting the device, and then more
type specific attributes or sub-elements as needed. If 'type' was not
specified then use a default of 'pty', since that gives compatability with
existing practice.
As an illustrative example
/*
* Parse the XML definition for a character device
*
* Top level node will be <console> or <parallel>, but all attributes
* and sub-elements are identical.
*
* type=vc|pty|null|host|file|pipe|udp|tcp|telnet, default is pty
*
* <console type='vc'/>
*
* <console type='pty' pty='/dev/pts/3'/>
*
* <console type='null'/>
*
* <console type='host' port='3'/>
*
* <console type='file' path='/some/file'/>
*
* <console type='pipe' path='/some/file'/>
*
* <console type='udp'>
* <sendto port='12356'/>
* </console>
*
* <console type='udp'>
* <sendto addr='127.0.0.1' port='12356'/>
* </console>
*
* <console type='udp'>
* <sendto addr='127.0.0.1' port='12356'/>
* <bind port='12356'/>
* </console>
*
* <console type='udp'>
* <sendto addr='127.0.0.1' port='12356'/>
* <bind addr='127.0.0.1' port='12356'/>
* </console>
*
* <console type='tcp'>
* <listen port='12356'/>
* </console>
*
* <console type='tcp'>
* <listen addr='127.0.0.1' port='12356'>
* <nowait/>
* <nodelay/>
* </listen>
* </console>
*
* <console type='tcp'>
* <connect addr='127.0.0.1' port='12356'>
* <nodelay/>
* </connect>
* </console>
*
* <console type='telnet'>
* <listen addr='127.0.0.1' port='12356'/>
* </console>
*
* <console type='telnet'>
* <connect addr='127.0.0.1' port='12356'/>
* </console>
*
*/
BTW, the udp, tcp, telnet options are only available on QEMU >= 0.9.0. We
already have ability to detect / validate that for both Xen & QEMU drivers.
NB, whereever there are IP addresses, hostnames can be used too, hence I
call the attriute 'addr' instead of 'ip'
Regards,
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
16 years, 9 months
[Libvir] Segfault with invalid virConnectPtr
by Richard W.M. Jones
Program terminated with signal 11, Segmentation fault.
#0 0x0000003d8b472a1b in free () from /lib64/libc.so.6
(gdb) bt
#0 0x0000003d8b472a1b in free () from /lib64/libc.so.6
#1 0x00002aaaaaae8dd7 in virResetError (err=0x33535c8) at virterror.c:111
#2 0x00002aaaaaae8fce in __virRaiseError (conn=0x33535a0, dom=0x0,
net=0x0,
domain=0, code=6, level=VIR_ERR_ERROR,
str1=0x2aaaaab0c678 "invalid connection pointer in %s",
str2=0x2aaaaab08560 "virConnectNumOfDomains", str3=0x0, int1=0,
int2=0,
msg=0x2aaaaab0c678 "invalid connection pointer in %s") at
virterror.c:358
#3 0x00002aaaaaacfa8e in virLibConnError (conn=0x33535a0,
error=VIR_ERR_INVALID_CONN, info=0x2aaaaab08560
"virConnectNumOfDomains")
at libvirt.c:127
#4 0x00002aaaaaad1052 in virConnectNumOfDomains (conn=0x736e6961)
at libvirt.c:758
#5 0x000000000043fa4e in ?? ()
A preliminary look at the code seems to indicate a fault in this logic:
int
virConnectNumOfDomains(virConnectPtr conn)
{
DEBUG("conn=%p", conn);
if (!VIR_IS_CONNECT(conn)) {
virLibConnError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
The VIR_IS_CONNECT macro is defined as:
#define VIR_CONNECT_MAGIC 0x4F23DEAD
#define VIR_IS_CONNECT(obj) ((obj) && (obj)->magic==VIR_CONNECT_MAGIC)
Obviously if VIR_IS_CONNECT fails then "conn" should not be used
further, so calling virLibConnError (conn, ...) is wrong. Personally I
think when we detect memory corruption in a C program we should just
call abort().
I'll see if I can come up with a patch to fix this later ... at the
moment I'm more interested in why my program is passing an invalid
connection pointer in the first place :-(
Rich.
--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in
England and Wales under Company Registration No. 03798903
17 years, 2 months
[Libvir] Extending libvirt to probe NUMA topology
by Ryan Harper
Hello all,
I wanted to start a discussion on how we might get libvirt to be able to
probe the NUMA topology of Xen and Linux (for QEMU/KVM). In Xen, I've
recently posted patches for exporting topology into the [1]physinfo
hypercall, as well adding a [2]hypercall to probe the Xen heap. I
believe the topology and memory info is already available in Linux.
With these, we have enough information to be able to write some simple
policy above libvirt that can create guests in a NUMA-aware fashion.
I'd like to suggest the following for discussion:
(1) A function to discover topology
(2) A function to check available memory
(3) Specifying which cpus to use prior to domain start
Thoughts?
1. http://lists.xensource.com/archives/html/xen-devel/2007-06/msg00298.html
2. http://lists.xensource.com/archives/html/xen-devel/2007-06/msg00299.html
--
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253 T/L: 678-9253
ryanh(a)us.ibm.com
17 years, 2 months
[Libvir] feature sujestions
by Márcio Parise Boufleur
Hello, I'm a grad student from Brazil. I was looking for some
interesting project to do as my final work and it I think that
contributing to your project would be a great achievement to me.
Do you have some kind list with feature suggestions? I am
particularly interested in remote administration. I helped a colleague
to write a graphical tool to administrate a remote Xen site last year.
Thank you.
MB
--
Computers are useless;
they can only give you answers!
-- Picasso
17 years, 2 months
[Libvir] libvirt on Windows
by Ronald Long
I am trying to talk to a 4.0.1 Xen Hypervisor (not Xen underneath a Linux
Distro) (via Python) from a Windows box.
(Am able to successfully connect and communicate using the Xen API Python
bindings).
Looks like at the very least I need to build libvirtmon.la from the c
sources.
Am I just dealing with "beginneritis", or trying to do something (run from
Windows) that
hasn't been done before?
thanks
ronald
17 years, 3 months
[Libvir] Ruby bindings for libvirt
by Meng Kuan
Hi,
I am exploring the possibility of creating ruby bindings for libvirt.
The only attempt I found after some searching is this:
http://www.cs.ucsb.edu/~ckrintz/racelab/jisha/
Following the SWIG method as described in the above URL, I have
gotten to the following point:
[root@dell1 libvirt_ruby]# irb
irb(main):001:0> require 'libvirt_ruby'
=> true
irb(main):002:0> conn = Libvirt_ruby.virConnectOpenReadOnly("")
=> #<SWIG::TYPE_p__virConnect:0x2aaaaabc46c8>
irb(main):003:0> dom = Libvirt_ruby.virDomainLookupByID(conn, 0)
=> #<SWIG::TYPE_p__virDomain:0x2aaaaabb5df8>
irb(main):004:0> ret = Libvirt_ruby.virDomainGetInfo(dom, info)
NameError: undefined local variable or method `info' for main:Object
from (irb):4
irb(main):005:0>
I am not sure how to create and pass in a ptr to a virDomainInfo
struct object into the virDomainGetInfo call within ruby.
Note that I was trying to following the info1.c example on the
libvirt website:
http://libvirt.org/examples/info1.c
As you can tell, this is the first time I am trying to create any
sort of language bindings for a C library.
Some questions:
1. Is there a better way of creating ruby bindings for libvirt
besides SWIG? If so, any pointers on what should be done?
2. Alternatively I can try to make my ruby code use libvirt-python
bindings as a python library. Has anyone done so? Any problems with
this approach?
cheers,
mengkuan
17 years, 3 months
[Libvir] --without-*
by Mark Johnson
Hi all,
Merging up to 0.3.2 on Solaris finally.. I had a couple of things on my list
of hacked patches, and not being a configure expert I figured I would
ask here...
How hard it is to change the config logic to account for the various
--without's.
e.g.
--without-qemu,
o ./Makefile.in - SUBDIRS shouldn't include qemud
o ./src/Makefile.in
o am__objects_1 shouldn't include:
o libvirt_la-bridge.lo
o libvirt_la-iptables.lo
o libvirt_la-qemu_driver.lo
o libvirt_la-qemu_conf.lo
o client sources, build rules, etc for the above.
--without-test (Incuding srcs, rules, etc)
o libvirt_la-test.lo, etc...
--without-xen (Incuding srcs, rules, etc)
o libvirt_la-xen_internal.lo
o libvirt_la-xs_internal.lo
o libvirt_la-xend_internal.lo
--without-remote (Incuding srcs, rules, etc)
o libvirt_la-remote_internal.lo
o am_libvirt_la_OBJECTS shouldn't include am__objects_2
One other thing I was curious about... I noticed the remote code
uses remote_protocol* out of the ./qemud dir.. I was just curious if
I should expect that to move somewhere else soon, or if you were
going to leave it there?
Thanks,
Mark.
17 years, 3 months
[Libvir] [PATCH] Fix endless loop of VirBufferVSprintf()
by Masayuki Sunou
Hi
VirBufferVSprintf() loops endless when it receives over 2000 bytes,
because the return value of vsnprintf() is more than "size - 1".
It is because the maximum of "size" is 1999 bytes.
--> the maximum of "buf->size - buf->use" = 2000
(1000(argument of virBufferGrow()) + 1000(set in virBufferGrow()))
So, virBufferEscapeString() has the same problem.
This patch sets to virBufferGrow() the size of the data
which VirBufferVSprintf()(virBufferEscapeString()) received
when it is over 1000 bytes.
Signed-off-by: Masayuki Sunou <fj1826dm(a)aa.jp.fujitsu.com>
Thanks,
Masayuki Sunou.
----------------------------------------------------------------------
Index: src/buf.c
===================================================================
RCS file: /data/cvs/libvirt/src/buf.c,v
retrieving revision 1.3
diff -u -p -r1.3 buf.c
--- src/buf.c 9 Jul 2007 11:24:52 -0000 1.3
+++ src/buf.c 24 Aug 2007 05:56:37 -0000
@@ -159,7 +159,7 @@ virBufferContentAndFree (virBufferPtr bu
int
virBufferVSprintf(virBufferPtr buf, const char *format, ...)
{
- int size, count;
+ int size, count, grow_size;
va_list locarg, argptr;
if ((format == NULL) || (buf == NULL)) {
@@ -172,7 +172,8 @@ virBufferVSprintf(virBufferPtr buf, cons
locarg)) < 0) || (count >= size - 1)) {
buf->content[buf->use] = 0;
va_end(locarg);
- if (virBufferGrow(buf, 1000) < 0) {
+ grow_size = (count > 1000) ? count : 1000;
+ if (virBufferGrow(buf, grow_size) < 0) {
return (-1);
}
size = buf->size - buf->use - 1;
@@ -198,7 +199,7 @@ virBufferVSprintf(virBufferPtr buf, cons
int
virBufferEscapeString(virBufferPtr buf, const char *format, const char *str)
{
- int size, count, len;
+ int size, count, len, grow_size;
char *escaped, *out;
const char *cur;
@@ -248,7 +249,8 @@ virBufferEscapeString(virBufferPtr buf,
while (((count = snprintf(&buf->content[buf->use], size, format,
(char *)escaped)) < 0) || (count >= size - 1)) {
buf->content[buf->use] = 0;
- if (virBufferGrow(buf, 1000) < 0) {
+ grow_size = (count > 1000) ? count : 1000;
+ if (virBufferGrow(buf, grow_size) < 0) {
free(escaped);
return (-1);
}
----------------------------------------------------------------------
17 years, 3 months
[Libvir] ANNOUNCE: virt-top 0.3.2.5 released
by Richard W.M. Jones
I'm pleased to announce a new release of virt-top, which is a utility
like 'top' that works for virtual machines. Many keys and command line
options are the same as for ordinary top.
Thanks to all the people who have been playing with it and sending me
feedback.
This version adds block device and network statistics (if supported by
the hypervisor and libvirt). This version also fixes a bug where it
would fail silently if unable to contact the hypervisor.
Main page:
http://et.redhat.com/~rjones/virt-top/
Source and binaries for several architectures available from:
http://et.redhat.com/~rjones/virt-top/download.html
If you have Fedora 7, this will probably work:
yum --enablerepo=development install virt-top
Rich.
--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in
England and Wales under Company Registration No. 03798903
17 years, 3 months
[Libvir] [PATCH] TX/RX network stats are swapped
by Richard W.M. Jones
I noticed that the stats reported by virDomainInterfaceStats appeared to
be swapped around. If the domain was downloading a lot of information,
then tx_bytes would increase quickly (I'd expect rx_bytes to increase
more if the domain was downloading).
The problem is that xen_internal.c measures the TX/RX from the point of
view of dom0. So that if dom0 is TRANSMITTING a lot of data up to the
domain, then that domain is really RECEIVING it.
Yes, I feel like an idiot ...
Fix attached.
Rich.
--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in
England and Wales under Company Registration No. 03798903
17 years, 3 months