[libvirt-users] Getting IP address of a lxc container via libvirt
by Harish Vishwanath
Hello
I wanted to understand if there is a way to get LXC container's ip address.
- virDomainInterfaceAddresses API only works for qemu/kvm and not with the
lxc driver.
What other options do I have?
Using enter-lxc-namespace is throwing this error:
virsh -c lxc:/// lxc-enter-namespace <domain> --noseclabel /sbin/ifconfig
libvirt: error : Expected at least one file descriptor
Appreciate any help.
Regards,
Harish
8 years, 8 months
[libvirt-users] migrate a guest from VMware to KVM
by Andrei Perietanu
I am trying to migrate a VMware guest to KVM. I have the .vmdk file which I
convert to qcow2 format using qemu-img convert.
The next step is to import the new img file.
If I use virt-install --import <guest config options> it all works fine.
But when I try the same think using the libvirt API I get the "no boot disk
found" message when starting the vm.
When importing the VM through the libvirtAPI, I use the same xml
description virsh outputs (dumpxml) after initially doing the import.
xml - the description I got using virsh xmldump <domain name>
xmlDesx = xml
conn.defineXML(xmlDesc)
One other important aspect is I am using a directory storage pool to store
all my volumes (.img files).
When I use virsh to import the vm, the storage pool recognizes the new
volume (the .img file I converted from the .vmdk file). But when I use the
libvirtAPI, it does not.
So my guess is that because the storage pool does not see the new volume
when I import the vm is the reason I get the "no boot disk found message".
Is there a way to tell the storage pool about the new volume?
What exactly does virsh do and I am not ?
Thanks,
Andrei
--
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of or
taking of any action in reliance upon this information by persons or
entities other than the intended recipient is prohibited. If you receive
this in error please contact the sender and delete the material from any
computer immediately. It is the policy of Klas Limited to disavow the
sending of offensive material and should you consider that the material
contained in the message is offensive you should contact the sender
immediately and also your I.T. Manager.
Klas Telecom Inc., a Virginia Corporation with offices at 1101 30th St. NW,
Washington, DC 20007.
Klas Limited (Company Number 163303) trading as Klas Telecom, an Irish
Limited Liability Company, with its registered office at Fourth Floor, One
Kilmainham Square, Inchicore Road, Kilmainham, Dublin 8, Ireland.
8 years, 8 months
[libvirt-users] Passing a USB hub
by Ruben Torrero Marijnissen
Hi,
I'm trying to assign a complete USB Hub to my Windows 10 guest, using
libvirt 1.3. Following the documentation, I tried adding the following
to the definition of my guest:
...
<devices>
..
<hub type='usb'>
<address type='usb' bus='1' port='10.2'/>
</hub>
..
</devices>
To get the correct port, I used lsusb:
[root@nobill-main 004]# lsusb -t
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/10p, 5000M
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/16p, 480M
|__ Port 5: Dev 110, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 1: Dev 52, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 1: Dev 53, If 0, Class=Human Interface Device,
Driver=usbhid, 12M
|__ Port 1: Dev 53, If 1, Class=Human Interface Device,
Driver=usbhid, 12M
|__ Port 3: Dev 54, If 0, Class=Human Interface Device,
Driver=usbhid, 12M
|__ Port 3: Dev 54, If 1, Class=Human Interface Device,
Driver=usbhid, 12M
|__ Port 3: Dev 54, If 2, Class=Human Interface Device,
Driver=usbhid, 12M
|__ Port 4: Dev 55, If 1, Class=Human Interface Device,
Driver=usbhid, 12M
|__ Port 10: Dev 117, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 2: Dev 118, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 11: Dev 8, If 0, Class=Human Interface Device,
Driver=usbhid, 1.5M
|__ Port 11: Dev 8, If 1, Class=Human Interface Device,
Driver=usbhid, 1.5M
(I want to assign port 10 in bus 1, the one that (still) has nothing
attached to it.
I can save it correctly, but after doing so, the guest wont start,
complaining it can't find bus with index 1. After playing with lots of
different configurations, my conclusions are:
- Any other bus different than 0, will make virt-manager instantly
complain that it cant find the bus (weird, since bus 0 doesn't exist
according to lsusb)
- Some ports allow the guest to start, but I won't be able to see the
hub on windows.
- Some other ports make virt-manager complain that it can't find
anything attached there.
Has anyone managed to get this working?
Thanks,
Rubén
8 years, 8 months
[libvirt-users] Questions about qcow2 file size management
by Jérôme
Hi all.
I have a few questions regarding the qcow2 format.
1/ Allocated size vs. file size
When creating a VM, I indicated a size of 10 G.
$ls -lsh
7,7G -rw------- 1 libvirt-qemu libvirt-qemu 11G oct. 14 10:04
prod.qcow2
The allocated size is lesser than max size. Alright.
I think I more or less grab the difference between allocated size and
file size, but I'm not sure I get the point of the auto-grow feature of
qcow2.
Can someone confirm that if I have, say, a 60Go partition, I can create
more than six 10Go VM, as long as each don't actually use the full 10
Go? Sort of like flying companies selling more tickets than seats in the
plane assuming a few people won't come.
In other words, can I have this on a 60Go drive?
total 53G
7,4G -rw------- 1 root root 11G oct. 8 06:34 prod_151008.qcow2
7,4G -rw------- 1 root root 11G oct. 9 06:37 prod_151009.qcow2
7,5G -rw------- 1 root root 11G oct. 10 06:41 prod_151010.qcow2
7,5G -rw------- 2 root root 11G oct. 11 06:49 prod_151011.qcow2
7,5G -rw------- 1 root root 11G oct. 12 06:44 prod_151012.qcow2
7,5G -rw------- 1 root root 11G oct. 13 06:27 prod_151013.qcow2
7,7G -rw------- 1 root root 11G oct. 14 06:55 prod_151014.qcow2
(Total allocated is 53 < 60 but sum of 11G sizes is 77 G.)
If so, then I guess I get the point.
2/ Backup size
Is there a simple way to do backups that only take the actual allocated
space (7,7 G in my example) instead of the max (10 G)?
I'm using snapshots and blockcommits to backup a VM, thanks to help on
this list. The scripts are on GitHub for anyone interested [1].
Basically, what the script does is snapshot then cp as local backup
file. Then rsync to another backup partition. Both source and
destination partitions are ext4.
Source dir (where I cp the snapshots):
# ls -lsh vmbackup/daily/
total 53G
7,4G -rw------- 1 root root 11G oct. 8 06:34 prod_151008.qcow2
7,4G -rw------- 1 root root 11G oct. 9 06:37 prod_151009.qcow2
7,5G -rw------- 1 root root 11G oct. 10 06:41 prod_151010.qcow2
7,5G -rw------- 2 root root 11G oct. 11 06:49 prod_151011.qcow2
7,5G -rw------- 1 root root 11G oct. 12 06:44 prod_151012.qcow2
7,5G -rw------- 1 root root 11G oct. 13 06:27 prod_151013.qcow2
7,7G -rw------- 1 root root 11G oct. 14 06:55 prod_151014.qcow2
Destination (where rsync copies the files):
# ls -lsh /mnt/usb_hd/vm/vmbackup/daily/
total 71G
11G -rw------- 1 root root 11G oct. 8 06:34 prod_151008.qcow2
11G -rw------- 1 root root 11G oct. 9 06:37 prod_151009.qcow2
11G -rw------- 1 root root 11G oct. 10 06:41 prod_151010.qcow2
11G -rw------- 2 root root 11G oct. 11 06:49 prod_151011.qcow2
11G -rw------- 1 root root 11G oct. 12 06:44 prod_151012.qcow2
11G -rw------- 1 root root 11G oct. 13 06:27 prod_151013.qcow2
11G -rw------- 1 root root 11G oct. 14 06:55 prod_151014.qcow2
Allocated size is as big as file size. This kind of beats the point of
having qcow2 grow as needed.
Ideally, I would like to create VM with a huge max file size, but only
backup the actually used space. How may I achieve this?
I just tested
qemu-img convert -O qcow2 prod_151008.qcow2 prod_151008_resize.qcow2
and I get
7,2G -rw-r--r-- 1 root root 7,2G oct. 14 10:51 prod_151008_resize.qcow2
Seems to work. I could do this before rsyncing.
Is this the recommanded way? Is there a higher level libvirt command to
use instead of qemu-img?
3/ Playing with allocated space
My VM apparently has an allocated size of 7.7 G
7,7G -rw------- 1 libvirt-qemu libvirt-qemu 11G oct. 14 10:04
prod.qcow2
However, loging into it shows much less than 7.7 G is used:
$df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 9.8G 2.0G 7.3G 22% /
udev 10M 0 10M 0% /dev
tmpfs 2.0G 17M 2.0G 1% /run
tmpfs 4.9G 4.0K 4.9G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 4.9G 0 4.9G 0% /sys/fs/cgroup
tmpfs 1003M 0 1003M 0% /run/user/1000
I understand once qcow2 has grown to a given allocated size, it won't
de-allocate space automatically (auto-allocation is one way only).
Perhaps I ended up loading 7Go of files, then those were deleted and now
only 2Go are used but the file still has 7G allocated. Could be, but I
don't see when this might have happened. Could there be another
explanation?
Say I want to minimize allocated space because it is a pity to use 2 Go
and keep 7 Go backups (I know disk space is cheap, this is just an
example), how may I shrink allocated space to currently used space?
I'm not talking about shrinking the file, just minimizing the allocated
size to keep small backups as per former paragraph, still keeping max
file size big to let the VM grow further when needed.
In other words, I'm aiming at
2,7G -rw------- 1 libvirt-qemu libvirt-qemu 11G oct. 14 10:04
prod.qcow2
not at
2,7G -rw------- 1 libvirt-qemu libvirt-qemu 2,7G oct. 14 10:04
prod.qcow2
The guest is a Linux, BTW.
4/ Playing with qcow2 file sizes
Say I've got this file
7,7G -rw------- 1 libvirt-qemu libvirt-qemu 11G oct. 14 10:04
prod.qcow2
I'd like to make it bigger, like
7,7G -rw------- 1 libvirt-qemu libvirt-qemu 100G oct. 14 10:04
prod.qcow2
AFAIU, the steps would be
- power off the VM
- expand the qcow2 file size
- from the host, extend the volume
- power on the VM
- from the guest, extend the filesystem
I've seen various post on the internet but I'm a bit confused and some
posts may be to old to consider new libvirt/qemu possibilities, so I'd
appreciate a safe pointer. (I'm also interested in reducing file size.)
Thanks for any hint.
[1] https://github.com/Jerome-github/vmbackup
--
Jérôme
8 years, 8 months
[libvirt-users] vdsm / qemu agent Windows sources
by Jean-Pierre Ribeauville
Hi,
Where may I find vdsm or qemu guest agent Windows sources since I want to check how they retrieve and open their relevant channel devices ?
Thx for help.
Regards,
J.P. Ribeauville
P: +33.(0).1.47.17.20.49
.
Puteaux 3 Etage 5 Bureau 4
jpribeauville(a)axway.com<mailto:jpribeauville@axway.com>
http://www.axway.com<http://www.axway.com/>
P Pensez à l'environnement avant d'imprimer.
8 years, 8 months
[libvirt-users] Slow boot when no serial pty connected
by David Caro
Hi everyone!
It's the first time I send a message to this list, I hope it's not the last :)
So my issue is that when booting a disk image generated with virt-builder [1]
it takes more than 5 minutes, waiting in the boot screen that says:
"
Booting from disk...
press any key to continue.
"
The press any key message shows up to 5 times. The issue is that it stays in
that screen for more than 5 min.
If I attach a serial pty device, then it takes ~5 seconds to go through that
screen (same messages, just show faster).
I don't want to have to create a pty device each time I want to spin up a vm
(if there's a way to tell libvirt to do that for me that would be ok too).
Is there any workaround I can do to avoid having to create a pty and still get
fast boot?
The xml of the slow vm:
<domain type='kvm'>
<name>fedora23</name>
<memory unit='MiB'>2048</memory>
<vcpu>1</vcpu>
<cpu mode='host-passthrough'>
<topology sockets='1' cores='1' threads='1'/>
</cpu>
<os>
<type arch='x86_64' machine='pc'>hvm</type>
<boot dev='hd'/>
<bootmenu enable='yes' timeout='3000'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/tmp/fedora-23.qcow2'/>
<target dev='sda' bus='virtio'/>
</disk>
<graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0' keymap='en-us'/>
<channel type='unix'>
<source mode='bind'/>
<target type='virtio' name='org.qemu.guest_agent.0'/>
</channel>
</devices>
</domain>
The same with this device boots fast:
<serial type='pty'>
<source path='/dev/pts/12'/>
<target port='0'/>
<alias name='serial0'/>
</serial>
The libvirt/qemu/kvm versions I'm using:
ipxe-roms-qemu-20150407-3.gitdc795b9f.fc23.noarch
libvirt-1.2.18.1-2.fc23.x86_64
libvirt-client-1.2.18.1-2.fc23.x86_64
libvirt-daemon-1.2.18.1-2.fc23.x86_64
libvirt-daemon-config-network-1.2.18.1-2.fc23.x86_64
libvirt-daemon-config-nwfilter-1.2.18.1-2.fc23.x86_64
libvirt-daemon-driver-interface-1.2.18.1-2.fc23.x86_64
libvirt-daemon-driver-libxl-1.2.18.1-2.fc23.x86_64
libvirt-daemon-driver-lxc-1.2.18.1-2.fc23.x86_64
libvirt-daemon-driver-network-1.2.18.1-2.fc23.x86_64
libvirt-daemon-driver-nodedev-1.2.18.1-2.fc23.x86_64
libvirt-daemon-driver-nwfilter-1.2.18.1-2.fc23.x86_64
libvirt-daemon-driver-qemu-1.2.18.1-2.fc23.x86_64
libvirt-daemon-driver-secret-1.2.18.1-2.fc23.x86_64
libvirt-daemon-driver-storage-1.2.18.1-2.fc23.x86_64
libvirt-daemon-driver-uml-1.2.18.1-2.fc23.x86_64
libvirt-daemon-driver-vbox-1.2.18.1-2.fc23.x86_64
libvirt-daemon-driver-xen-1.2.18.1-2.fc23.x86_64
libvirt-daemon-kvm-1.2.18.1-2.fc23.x86_64
libvirt-gconfig-0.2.2-1.fc23.x86_64
libvirt-glib-0.2.2-1.fc23.x86_64
libvirt-gobject-0.2.2-1.fc23.x86_64
libvirt-python-1.2.18-1.fc23.x86_64
qemu-common-2.4.1-1.fc23.x86_64
qemu-guest-agent-2.4.1-1.fc23.x86_64
qemu-img-2.4.1-1.fc23.x86_64
qemu-kvm-2.4.1-1.fc23.x86_64
qemu-system-x86-2.4.1-1.fc23.x86_64
Thanks!!
[1] The image was created with the command:
$ virt-builder --format=qcow2 fedora-23
--
David Caro
Red Hat S.L.
Continuous Integration Engineer - EMEA ENG Virtualization R&D
Tel.: +420 532 294 605
Email: dcaro(a)redhat.com
IRC: dcaro|dcaroest@{freenode|oftc|redhat}
Web: www.redhat.com
RHT Global #: 82-62605
8 years, 8 months
[libvirt-users] libvirt domain configuration xml
by Andrei Perietanu
I am trying to change a domain configuration from a python script. More
specific, I want to edit the VNC settings. You can't do this using the
libvirt API so you have to edit the domain configuration:
Fo exmple, to disable VNC for a domain 'test1':
vmXml = vm.XMLDesc(0)
root = ET.fromstring(vmXml)
devices = root.find('./devices')
graphics = devices.find('graphics')
devices.remove(graphics)
xml = ET.tostring(root)
with open('path_to/test1.xml', 'w') as f:
f.write(xml)
not the problem is with the test1.xml. Even though the domain configuration
seems to be stored there, the file seems to be regenerated/overwritten so
any changes I make will not take effect.
So the question really is: where is the domain configuration stored? Am I
editing the write file, or am I missing something?
Thanks,
Andrei
--
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of or
taking of any action in reliance upon this information by persons or
entities other than the intended recipient is prohibited. If you receive
this in error please contact the sender and delete the material from any
computer immediately. It is the policy of Klas Limited to disavow the
sending of offensive material and should you consider that the material
contained in the message is offensive you should contact the sender
immediately and also your I.T. Manager.
Klas Telecom Inc., a Virginia Corporation with offices at 1101 30th St. NW,
Washington, DC 20007.
Klas Limited (Company Number 163303) trading as Klas Telecom, an Irish
Limited Liability Company, with its registered office at Fourth Floor, One
Kilmainham Square, Inchicore Road, Kilmainham, Dublin 8, Ireland.
8 years, 8 months
[libvirt-users] block-commit fails
by Fırat KÜÇÜK
Hello,
one of my VM's blockcommit job always fails. How can I find the reason?
Error message is not clear.
virsh snapshot-create-as --domain my-vm backup-snapshot \
--diskspec vda,file=/foo/my-vm-snapshot.img \
--disk-only --atomic --no-metadata
virsh blockcommit my-vm vda --active --verbose --wait --async
virsh blockjob my-vm vda --pivot
internal error: unable to execute QEMU command 'block-job-complete': The
active block job for device 'drive-virtio-disk0' cannot be completed
8 years, 8 months
[libvirt-users] problem with bond/team network interfaces
by Nerijus Baliunas
Hello,
I already asked similar question on May 2014. Then it started
to work on CentOS 7.0 and 7.1. Now it fails again on 7.2.
Setup is 2 network cards in a team, and then bridge between team and vnet0.
The problem is, that I can ping KVM guest from host, but not from LAN.
>From KVM host:
arping -I br0 192.168.0.200
ARPING 192.168.0.200 from 192.168.0.201 br0
Unicast reply from 192.168.0.200 [52:54:00:AB:50:C9] 0.869ms
Unicast reply from 192.168.0.200 [52:54:00:AB:50:C9] 0.937ms
...
^CSent 8 probes (1 broadcast(s))
Received 8 response(s)
>From LAN (other host on the same network):
arping -I eth1 192.168.0.200
ARPING 192.168.0.200 from 192.168.0.254 eth1
Unicast reply from 192.168.0.200 [52:54:00:AB:50:C9] 1.061ms
^CSent 5 probes (1 broadcast(s))
Received 1 response(s)
Regards,
Nerijus
8 years, 8 months