[libvirt-users] snapshot of a raw file - how to revert ?
by Lentes, Bernd
Hi,
i have the following system:
pc59093:~ # cat /etc/os-release
NAME="SLES"
VERSION="11.4"
VERSION_ID="11.4"
PRETTY_NAME="SUSE Linux Enterprise Server 11 SP4"
ID="sles"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sles:11:4"
pc59093:~ # uname -a
Linux pc59093 3.0.101-84-default #1 SMP Tue Oct 18 10:32:51 UTC 2016 (15251d6) x86_64 x86_64 x86_64 GNU/Linux
pc59093:~ # rpm -qa|grep -iE 'libvirt|kvm'
libvirt-cim-0.5.12-0.7.16
libvirt-python-1.2.5-1.102
libvirt-client-1.2.5-15.3
kvm-1.4.2-47.1
sles-kvm_en-pdf-11.4-0.33.1
libvirt-1.2.5-15.3
I have several guests running with raw files, which is sufficent for me. Now i'd like to snapshot one guest because i make heavy configuration changes on it.
>From what i read in the net is that libvirt supports snapshoting of raw files when the guest is shutdown and the file of the snapshot becomes a qcow2. Right ?
I try to avoid converting my raw file to a qcow2 file. I can shutdown the guest for a certain time, that's no problem. I don't need a live snapshot.
But how can i revert to my previous state if my configuration changes go wrong ?
Can i do this with snapshot-revert or do i have to edit the xml file and point the hd again to the origin raw file ?
What i found in the net wasn't complete clear.
Thanks.
Bernd
--
Bernd Lentes
Systemadministration
Institut für Entwicklungsgenetik
Gebäude 35.34 - Raum 208
HelmholtzZentrum münchen
[ mailto:bernd.lentes@helmholtz-muenchen.de | bernd.lentes(a)helmholtz-muenchen.de ]
phone: +49 89 3187 1241
fax: +49 89 3187 2294
[ http://www.helmholtz-muenchen.de/idg | http://www.helmholtz-muenchen.de/idg ]
no backup - no mercy
Helmholtz Zentrum München
6 years, 9 months
[libvirt-users] virt-install --connect lxc:///
by ales drtik
After reboot of the host i have different error message:
root@blade1:~# virt-install --connect lxc:/// --name test_LXC --memory 128 --filesystem /home/lxcuser/LXC,/ --init /bin/sh
WARNING No operating system detected, VM performance may suffer. Specify an OS with --os-variant for optimal results.
Starting install...
ERROR internal error: guest failed to start: Failure in libvirt_lxc startup: cannot find init path '/bin/sh' relative to container root: No such file or directory
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
virsh --connect lxc:/// start test_LXC
otherwise, please restart your installation.
root@blade1:~# ls -al /home/lxcuser/LXC
total 24
drwxr-xr-x 6 root root 4096 Mar 28 16:09 .
drwxr-xr-x+ 7 lxcuser lxcuser 4096 Mar 28 13:20 ..
drwxr-xr-x 2 root root 4096 Mar 28 16:09 dev
drwxr-xr-x 2 root root 4096 Mar 28 16:09 .oldroot
drwxr-xr-x 2 root root 4096 Mar 28 16:09 proc
drwxr-xr-x 2 root root 4096 Mar 28 16:09 sys
6 years, 9 months
[libvirt-users] virt-install --connect lxc:///
by ales drtik
Hi,
I would like to install LXC container by virt-install.
>From man:
virt-install \
--connect lxc:/// \
--name container \
--memory 128 \
--filesystem /home/LXC,/ \
--init /bin/sh
But my err is:
root@blade1:/home/lxcuser/LXC# virt-install --connect lxc:/// --name test_LXC --memory 128 --filesystem \ /home/lxcuser/LXC,/ --init /bin/sh
WARNING No operating system detected, VM performance may suffer. Specify an OS with --os-variant for optimal results.
Starting install...
ERROR internal error: guest failed to start: Failure in libvirt_lxc startup: Failed to create /home/lxcuser/LXC/.oldroot: Invalid argument
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
virsh --connect lxc:/// start test_LXC
otherwise, please restart your installation.
What is wrong with this?
6 years, 9 months
[libvirt-users] Attempt to define unprivileged LXC by libvirt
by ales drtik
Hi,
i converted LXC conf to xml by:
lxcuser@blade1:~/.local/share/lxc/test_deb$ virsh -c lxc:/// domxml-from-
native lxc-tools /home/lxcuser/.local/share/lxc/test_deb/config
<domain type='lxc'>
<name>test_deb</name>
<uuid>cce77799-89fd-41fd-99c1-101e00844e23</uuid>
<memory unit='KiB'>65536</memory>
<currentMemory unit='KiB'>65536</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64'>exe</type>
<init>/sbin/init</init>
</os>
<idmap>
<uid start='1258512' target='0' count='65536'/>
<gid start='1258512' target='0' count='65536'/>
</idmap>
<features>
<capabilities policy='allow'>
</capabilities>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/lib/libvirt/libvirt_lxc</emulator>
<filesystem type='mount' accessmode='passthrough'>
<source dir='/home/lxcuser/.local/share/lxc/test_deb/rootfs'/>
<target dir='/'/>
</filesystem>
<interface type='bridge'>
<mac address='00:16:3e:ab:21:1b'/>
<source bridge='br0'/>
<link state='up'/>
</interface>
</devices>
</domain>
Now attempt to define by virsh gives this err:
lxcuser@blade1:~/.local/share/lxc/test_deb$ virsh -c lxc:/// define tmp/test
_deb.xml
error: Failed to define domain from /tmp/test_deb.xml
error: unsupported configuration: You must map the root user of container
Debian stretch.
Where am I wrong ?
6 years, 9 months
[libvirt-users] 回复: Fwd: About libvirt domain snapshot problem(for single disk snapshot)
by James Iter
My negligence。
--
James Iter
在 2018年3月22日 星期四,下午11:02,Dominik Psenner 写道:
> I believe that Your mail went to the wrong recipient. As far as I'm
> concerned it should have been sent to the libvirt-users mailing list,
> shouldn't it?
>
>
> On 2018-03-22 15:55, James Iter wrote:
> > Thank your reply.
> > I found the method.
> > Now, I sharing to you.
> > When create snapshot, just add ’no’ value to the ’snapshot’ option with —diskspec.
> > As below:
> >
> > ``` bash
> > snapshot-create-as 8x0lbzvS --name sys_disk --disk-only --quiesce --atomic --diskspec "vda,snapshot=external" --diskspec "vdb,snapshot=no"
> > ```
> >
> >
> > --
> > James Iter
> >
> >
> > 在 2018年3月21日 星期三,下午6:24,Dominik Psenner 写道:
> >
> > > (shameless plug)
> > >
> > > To do automated daily backups of a few machines I wrote a small toolset to get the job done and make it as less a hassle as you can get. The source is on github https://github.com/dpsenner/libvirt-administration-tools/. Use it if you find it useful.
> > >
> > > Note that I have yet not tested it with multiple disks but the tool uses the output of `virsh dombklst`. In theory that should snapshot all disks of a guest machine.
> > >
> > > Cheers
> > > On Tue, 20 Mar 2018, 19:54 James Iter, <james.iter.cn(a)gmail.com (mailto:james.iter.cn@gmail.com)> wrote:
> > > >
> > > > Hi, dear friends.
> > > > My guest has two disks, vda and vdb. both are qcow2 local file.
> > > > When guest running state.
> > > > I want to take the vda snapshot of guest(just vda, no include vdb). but I met libvirt do snapshot for all disks of guest.
> > > >
> > > > About methods as follow:
> > > > 1、
> > > > ``` bash
> > > > virsh
> > > > snapshot-create-as 8x0lbzvS --name sys_disk3 --disk-only --diskspec "vda,snapshot=external"
> > > > ```
> > > > ``` result
> > > >
> > > > [root@10k03 ~]# ls -lh /opt/Images/*sys_disk3
> > > >
> > > >
> > > > -rw-------. 1 qemu qemu 194K 3月 20 23:27 /opt/Images/00d76a58-9637-4402-9739-21afd1246e06.sys_disk3
> > > >
> > > >
> > > > -rw-------. 1 qemu qemu 704K 3月 20 23:52 /opt/Images/8d582c1c-355a-4297-9434-2f2f562c77df.sys_disk3
> > > >
> > > >
> > > > ```
> > > >
> > > > 2、
> > > > ``` python
> > > >
> > > > #!/usr/bin/env python
> > > >
> > > >
> > > > # -*- coding: utf-8 -*-
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > import libvirt
> > > >
> > > >
> > > > import libvirt_qemu
> > > >
> > > >
> > > > import json
> > > >
> > > >
> > > > import sys
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > name = sys.argv[1]
> > > >
> > > >
> > > > print name
> > > >
> > > >
> > > > conn = libvirt.open()
> > > >
> > > >
> > > > dom = conn.lookupByName(name)
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > xml = """
> > > >
> > > >
> > > > <domainsnapshot>
> > > >
> > > >
> > > > <name>sysdisk_by_xml</name>
> > > >
> > > >
> > > > <description>By xml</description>
> > > >
> > > >
> > > > <disks>
> > > >
> > > >
> > > > <disk name='vda' snapshot='external'>
> > > >
> > > >
> > > > </disk>
> > > >
> > > >
> > > > </disks>
> > > >
> > > >
> > > > </domainsnapshot>
> > > >
> > > >
> > > > """
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > flags = 0
> > > >
> > > >
> > > > flags |= libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY
> > > >
> > > >
> > > > flags |= libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > ret = dom.snapshotCreateXML(xmlDesc=xml, flags=flags)
> > > >
> > > >
> > > > ```
> > > > ``` result
> > > >
> > > > [root@10k03 ~]# ls -lh /opt/Images/*sysdisk_by_xml
> > > >
> > > >
> > > > -rw-------. 1 qemu qemu 194K 3月 20 23:52 /opt/Images/00d76a58-9637-4402-9739-21afd1246e06.sysdisk_by_xml
> > > >
> > > >
> > > > -rw-------. 1 qemu qemu 1.2M 3月 21 00:03 /opt/Images/8d582c1c-355a-4297-9434-2f2f562c77df.sysdisk_by_xml
> > > >
> > > >
> > > > ```
> > > > 。
> > > >
> > > >
> > > > Then, I searched by google. see your page(https://www.redhat.com/archives/libvirt-users/2013-June/msg00102.html).
> > > >
> > > > Now, I want to ask you, have you found the method?
> > > >
> > > >
> > > > --
> > > > James Iter
> > > >
> > > >
> > > > _______________________________________________
> > > > libvirt-users mailing list
> > > > libvirt-users(a)redhat.com (mailto:libvirt-users@redhat.com)
> > > > https://www.redhat.com/mailman/listinfo/libvirt-users
> > > >
> > >
> > >
> >
> >
>
>
>
6 years, 9 months
[libvirt-users] Attempt to migrate guest to the same host localhost.localdomain
by llilulu
Hi
My libvirt version is 3.4.0, I migrate guest between two host, The two host have same hostname( hostname cmd output same), I try find solution on Internet, I find someone say host uuid same, But virsh sysinfo output uuid is different, when I change one host's hostname, migrate success. I wish know why, and Can I solution this problem not change hostname.
My program use api virDomainMigrateToURI2, flag arg is VIR_MIGRATE_LIVE | VIR_MIGRATE_PEER2PEER . I use virsh migrate --live --p2p.
Thanks
6 years, 9 months
Re: [libvirt-users] Persisting the libvirt guest's reason code.
by Daniel P. Berrangé
Re-adding the mailing list - please don't take discussions off-list
in this way.
On Tue, Mar 20, 2018 at 05:14:45PM +0000, Tanmoy Sinha wrote:
> Daniel,
>
> Thanks for your prompt response. I have another question, as soon as I do
> virsh save <GuestID> <filename>, the corresponding xml and pid under
> /var/run/libvirt/qemu is gone, but the guest still has a definition. At
> this point, if I query the domain state (i.e. virsh domstate --reason
> <GUESTID>) it reads shutoff(saved). Where does this fetch the reason from,
> when the /var/run/libvirt/qemu/Guestname.xml file is gone? Libvirtd
> maintains the reason code in-memory?
That's true only if the guest has a persistent config file in /etc/libvirt.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
6 years, 9 months
[libvirt-users] About libvirt domain snapshot problem(for single disk snapshot)
by James Iter
Hi, dear friend.
My guest has two disks, vda and vdb. both are qcow2 local file.
When guest running state.
I want to take the vda snapshot of guest(just vda, no include vdb). but I met libvirt do snapshot for all disks of guest.
About methods for follow:
1、
``` bash
virsh
snapshot-create-as 8x0lbzvS --name sys_disk3 --disk-only --diskspec "vda,snapshot=external"
```
``` result
[root@10k03 ~]# ls -lh /opt/Images/*sys_disk3
-rw-------. 1 qemu qemu 194K 3月 20 23:27 /opt/Images/00d76a58-9637-4402-9739-21afd1246e06.sys_disk3
-rw-------. 1 qemu qemu 704K 3月 20 23:52 /opt/Images/8d582c1c-355a-4297-9434-2f2f562c77df.sys_disk3
```
2、
``` python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import libvirt
import libvirt_qemu
import json
import sys
name = sys.argv[1]
print name
conn = libvirt.open()
dom = conn.lookupByName(name)
xml = """
<domainsnapshot>
<name>sysdisk_by_xml</name>
<description>By xml</description>
<disks>
<disk name='vda' snapshot='external'>
</disk>
</disks>
</domainsnapshot>
"""
flags = 0
flags |= libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY
flags |= libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE
ret = dom.snapshotCreateXML(xmlDesc=xml, flags=flags)
```
``` result
[root@10k03 ~]# ls -lh /opt/Images/*sysdisk_by_xml
-rw-------. 1 qemu qemu 194K 3月 20 23:52 /opt/Images/00d76a58-9637-4402-9739-21afd1246e06.sysdisk_by_xml
-rw-------. 1 qemu qemu 1.2M 3月 21 00:03 /opt/Images/8d582c1c-355a-4297-9434-2f2f562c77df.sysdisk_by_xml
```
。
Then, I search by google. see your page(https://www.redhat.com/archives/libvirt-users/2013-June/msg00102.html).
Now, I want to ask you, was you found the way?
--
James Iter
6 years, 9 months
[libvirt-users] Persisting the libvirt guest's reason code.
by Tanmoy Sinha
Hi,
I am currently facing an issue with libvirt w.r.t a guest's state and
reason code. Precisely following are steps:
1. I have a running guest named *linux-test *on KVM
2. I do a
* $> virsh save linux-test linux-saved.dat*
3. At this point
* $> virsh domstate --reason linux-test *shows *shutoff(saved)*
4. I restarted the libvirtd daemon
* $>systemctl restart libvirtd*
5. Now when I check for the domain state,
* $> virsh domstate --reason linux-test *it reads
*shutoff(unknown)*
>From what I understand:
The reason code for a particular state is maintained in-memory (no
persistence in libvirt). Now when libvirtd restarts it queries the qemu
monitor for all the running qemu processes and reassigns the state and
reason. But for guests which are in shutoff state, there’s exists no QEMU
instance for it, hence it has no way to know what was the last reason (i..e
the default value 0 or UNKNOWN), but the state remains as shutfoff!
Is there a patch for it? Or someway to retain the reason code across
reboots and restart?
Regards,
Tanmoy Sinha
6 years, 9 months