Skip to contentSkip to conversation

live saving of domU

DISCUSSION Jayesh Salvi 4 participants 9 messages May 10, 2006 – May 11, 2006

lore
Share & tools
lore
#0 lore raw

Hi,

Could anyone tell me, why 'xm save' has live parameter set to false by default. From yesterday's patch ([PATCH] [XenD] Migration-related change) i guess this paramter is renamed to network.

This is the piece of code I am talking about:
XendDomain.py:
def domain_save(self, domid, dst):
"""Start saving a domain to file.

@param dst: destination file
"""

try:
dominfo = self.domain_lookup_by_name_or_id_nr(domid) if not dominfo:
raise XendInvalidDomain(str(domid))

if dominfo.getDomid() == PRIV_DOMAIN:
raise XendError("Cannot save privileged domain %i" % domid)

fd = os.open(dst, os.O_WRONLY | os.O_CREAT | os.O_TRUNC) try:
---> # For now we don't support 'live checkpoint'
---> return XendCheckpoint.save(fd, dominfo, False)
finally:
os.close(fd)

I am interested in saving the state of a virtual machine to a file, but want to continue it running. I want to backup the state of the machine, so I want this to be unintrusive operation. I would like to pause the domU and save it to file but keeping it still in memory. After save to file is done I will unpause the domU.

I don't see why this shouldn't be possible if live migration works so well.

Is it possible? Are there any hidden xm options for doing live save, if not where can I tweak this?

Please let me know.

Thanks,
--
Jayesh
------------------------------------------------------------------------
Everything you can imagine is real

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 5 lines · Jayesh Salvi

Hi,

Could anyone tell me, why 'xm save' has live parameter set to false by default. From yesterday's patch ([PATCH] [XenD] Migration-related change) i guess this paramter is renamed to network.

This parameter has not been renamed -- the rename was for a similar flag passed in to the device migration code, but the live flag for migration remains.

Quoted 10 lines

[Snip]

I am interested in saving the state of a virtual machine to a file, but want to continue it running. I want to backup the state of the machine, so I want this to be unintrusive operation. I would like to pause the domU and save it to file but keeping it still in memory. After save to file is done I will unpause the domU.

I don't see why this shouldn't be possible if live migration works so well.

The reason it's not supported at the moment is this: if you take a snapshot of a VM, then run for a bit, and then try and run the snapshot against the same filesystem that you were using before, you will inevitably corrupt the filesystem.

If you had a way to snapshot the storage at the same time as the VM, then you could make live snapshotting of VMs work properly. As it is, this is not integrated into Xend at the moment, and not supported because of the danger of filesystem corruption if you don't know what you are doing.

Ewan.

#2 lore raw
Quoted 23 lines · Ewan Mellor
Quoted 6 lines · Jayesh Salvi

Hi,

Could anyone tell me, why 'xm save' has live parameter set to false by default. From yesterday's patch ([PATCH] [XenD] Migration-related change) i guess this paramter is renamed to network.

This parameter has not been renamed -- the rename was for a similar flag passed in to the device migration code, but the live flag for migration remains.

Quoted 8 lines

[Snip]

I am interested in saving the state of a virtual machine to a file, but want to continue it running. I want to backup the state of the machine, so I want this to be unintrusive operation. I would like to pause the domU and save it to file but keeping it still in memory. After save to file is done I will unpause the domU.

Quoted 9 lines
Quoted 3 lines

I don't see why this shouldn't be possible if live migration works so well.

The reason it's not supported at the moment is this: if you take a snapshot of a VM, then run for a bit, and then try and run the snapshot against the same filesystem that you were using before, you will inevitably corrupt the filesystem.

Moreover, you cannot dump the state of a domain after a pause and expect it to ever run again.

Guests are aware of the physical addresses of the memory that's been allocated to them. Because of this, to save a domain's state in a restorable way you need the guest to "canonicalize" itself. The only way to do this today is through a suspend operation which happens to be a subop of shutdown. Shutdowns are non-recoverable so you cannot use this as a snapshotting mechanism.

The closest thing you can achieve is a localhost migration. There are some caveats to this, of course. The first is that you need to have as much memory as the domain has available since you'll have a copy of the domain created briefly while the migration takes place. Migrations are also quite intrusive since they involve tearing down and bringing up all the devices.

I've gotten a lot of requests for light weight checkpointing. AFAIK, noone is actually working on it though.

Regards,

Anthony Liguori

Quoted 12 lines

If you had a way to snapshot the storage at the same time as the VM, then you could make live snapshotting of VMs work properly. As it is, this is not integrated into Xend at the moment, and not supported because of the danger of filesystem corruption if you don't know what you are doing.

Ewan.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
Quoted 43 lines · Anthony Liguori
Quoted 7 lines · Ewan Mellor
Quoted 4 lines · Jayesh Salvi

Hi,

Could anyone tell me, why 'xm save' has live parameter set to false by default. From yesterday's patch ([PATCH] [XenD] Migration-related

change)

Quoted 12 lines
Quoted 2 lines

i guess this paramter is renamed to network.

This parameter has not been renamed -- the rename was for a similar flag passed in to the device migration code, but the live flag for migration remains.

Quoted 4 lines

[Snip]

I am interested in saving the state of a virtual machine to a file, but want to continue it running. I want to backup the state of the machine,

so

Quoted 2 lines
Quoted 2 lines

I want this to be unintrusive operation. I would like to pause the domU and save it to file but keeping it still in memory. After save to file

is

Quoted 7 lines
Quoted 5 lines

done I will unpause the domU.

I don't see why this shouldn't be possible if live migration works so well.

The reason it's not supported at the moment is this: if you take a

snapshot of

Quoted 1 line

a VM, then run for a bit, and then try and run the snapshot against the

same

Quoted 3 lines

filesystem that you were using before, you will inevitably corrupt the filesystem.

Moreover, you cannot dump the state of a domain after a pause and expect it to ever run again.

Quoted 6 lines

Guests are aware of the physical addresses of the memory that's been allocated to them. Because of this, to save a domain's state in a restorable way you need the guest to "canonicalize" itself. The only way to do this today is through a suspend operation which happens to be a subop of shutdown. Shutdowns are non-recoverable so you cannot use this as a snapshotting mechanism.

Thanks, that was informative. But the shutdown you are refering to here is not the traditional shutdown of domU right? I mean 'xm shutdown' will do proper shutdown of domU OS, the shutdown you are referring while doing 'xm save' is different from that, I hope!

The closest thing you can achieve is a localhost migration. There are

Quoted 9 lines

some caveats to this, of course. The first is that you need to have as much memory as the domain has available since you'll have a copy of the domain created briefly while the migration takes place. Migrations are also quite intrusive since they involve tearing down and bringing up all the devices.

I've gotten a lot of requests for light weight checkpointing. AFAIK, noone is actually working on it though.

Regards,

Quoted 20 lines

Anthony Liguori

Quoted 1 line

If you had a way to snapshot the storage at the same time as the VM,

then you

Quoted 1 line

could make live snapshotting of VMs work properly. As it is, this is

not

Quoted 1 line

integrated into Xend at the moment, and not supported because of the

danger of

Quoted 9 lines

filesystem corruption if you don't know what you are doing.

Ewan.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

--
Jayesh
------------------------------------------------------------------------
Everything you can imagine is real

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw
Quoted 13 lines · Jayesh Salvi

On 5/10/06, *Anthony Liguori* <[email protected] <mailto:[email protected]>> wrote:

Guests are aware of the physical addresses of the memory that's been allocated to them. Because of this, to save a domain's state in a restorable way you need the guest to "canonicalize" itself. The only way to do this today is through a suspend operation which happens to be
a subop of shutdown. Shutdowns are non-recoverable so you cannot use this as a snapshotting mechanism.

Quoted 1 line

Thanks, that was informative. But the shutdown you are refering to here is not the traditional shutdown of domU right? I mean 'xm shutdown' will do proper shutdown of domU OS, the shutdown you are referring while doing 'xm save' is different from that, I hope!

From the perspective of the hypervisor, there isn't a significant difference between doing an "xm shutdown" or an "xm save". Don't read too much into that though b/c the vast majority of both operations are performed in userspace. Unfortunately, this lack of distinction in the hypervisor is what currently prevents light weight check pointing.

You could, theoritically, add another entry point in the guest kernel and use some xenstore magic to force the domain to spin in a loop after canonicalizing, pause it, switch a register value, then unpause it. Something like (in psuedo-code):

while (eax == 0) halt;

Right after canonicalizing. Then pause, and do a getvcpuinfo/setvcpuinfo to change eax to 1. Then unpause. If you added another suspend entry point you could probably even avoid tearing down the devices...

Regards,

Anthony Liguori

Quoted 41 lines

The closest thing you can achieve is a localhost migration. There are some caveats to this, of course. The first is that you need to have as
much memory as the domain has available since you'll have a copy of the
domain created briefly while the migration takes
place. Migrations are
also quite intrusive since they involve tearing down and bringing up all
the devices.

I've gotten a lot of requests for light weight checkpointing. AFAIK, noone is actually working on it though.

Regards,

Anthony Liguori

> If you had a way to snapshot the storage at the same time as the VM, then you
> could make live snapshotting of VMs work properly. As it is, this is not
> integrated into Xend at the moment, and not supported because of the danger of
> filesystem corruption if you don't know what you are doing. >
> Ewan.
>
> _______________________________________________
> Xen-devel mailing list
> [email protected] <mailto:[email protected]> > http://lists.xensource.com/xen-devel
>

Signature · 3 lines
Jayesh
------------------------------------------------------------------------
Everything you can imagine is real 
#5 lore raw
Quoted 34 lines · Anthony Liguori
Quoted 8 lines · Jayesh Salvi

On 5/10/06, *Anthony Liguori* <[email protected] <mailto:[email protected]>> wrote:

Guests are aware of the physical addresses of the memory that's been allocated to them. Because of this, to save a domain's state in a restorable way you need the guest to "canonicalize" itself. The

only

Quoted 3 lines

way to do this today is through a suspend operation which happens to be
a subop of shutdown. Shutdowns are non-recoverable so you cannot

use

Quoted 7 lines

this as a snapshotting mechanism.

Thanks, that was informative. But the shutdown you are refering to here is not the traditional shutdown of domU right? I mean 'xm shutdown' will do proper shutdown of domU OS, the shutdown you are referring while doing 'xm save' is different from that, I hope!

From the perspective of the hypervisor, there isn't a significant difference between doing an "xm shutdown" or an "xm save". Don't read too much into that though b/c the vast majority of both operations are performed in userspace. Unfortunately, this lack of distinction in the hypervisor is what currently prevents light weight check pointing.

You could, theoritically, add another entry point in the guest kernel and use some xenstore magic to force the domain to spin in a loop after canonicalizing, pause it, switch a register value, then unpause it. Something like (in psuedo-code):

Quoted 6 lines

while (eax == 0) halt;

Right after canonicalizing. Then pause, and do a getvcpuinfo/setvcpuinfo to change eax to 1. Then unpause. If you added another suspend entry point you could probably even avoid tearing down the devices...

While reading more on the topic of backup of virtual machines, I came across the problems and solutions in VMWare world. You can check out the VMWare consolidated backup (VCB) feature introduced in ESX server. (
http://blog.baeke.info/blog/_archives/2006/3/23/1836968.html).

The VCB addresses some different problems of backups in virtual environment, but points relevant to our current thread of conversation:
VCB does give a mechanism to quiesce the virtual machine. The virtual disk is mounted on something called junction point, there is some windows specific snapshot mechanism using which the snapshot of the disk is taken. Then traditional softwares are used to do backup this shapshot / junction point.

Quoted 1 line

From this I guess, sooner or later we will need such quisceing mechanism

working in Xen.

On a little different note, it is amusing to note that VMWare has to do some tricky dance of junction point/snapshot, etc. May be VMWare virtual machines principally use loopback file systems for virtual disk - that's why they have problem in viewing the same file system from dom0 and domU (consistent or inconsistent). Xen allows devices to be used as boot disk. Hence the file system is visible from dom0 and domU the same way (at least RO from dom0). I might be wrong. Correct me if you think so.

Regards,

Quoted 49 lines

Anthony Liguori

Quoted 1 line

The closest thing you can achieve is a localhost migration. There

are

Quoted 11 lines

some caveats to this, of course. The first is that you need to have as
much memory as the domain has available since you'll have a copy of the
domain created briefly while the migration takes place. Migrations are
also quite intrusive since they involve tearing down and bringing up all
the devices.

I've gotten a lot of requests for light weight

checkpointing. AFAIK,

Quoted 14 lines

noone is actually working on it though.

Regards,

Anthony Liguori

> If you had a way to snapshot the storage at the same time as the VM, then you
> could make live snapshotting of VMs work properly. As it is, this is not
> integrated into Xend at the moment, and not supported because of the danger of
> filesystem corruption if you don't know what you are doing. >

Quoted 5 lines

> Ewan.
>
> _______________________________________________ > Xen-devel mailing list
> [email protected] <mailto:

[email protected]>

Quoted 10 lines
Quoted 2 lines

http://lists.xensource.com/xen-devel

--
Jayesh
------------------------------------------------------------------------
Everything you can imagine is real

Signature · 3 lines
Jayesh
------------------------------------------------------------------------
Everything you can imagine is real

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#6 lore raw
Quoted 2 lines · Jayesh Salvi

On a little different note, it is amusing to note that VMWare has to do some tricky dance of junction point/snapshot, etc. May be VMWare virtual machines principally use loopback file systems for virtual disk - that's why they have problem in viewing the same file system from dom0 and domU (consistent or inconsistent). Xen allows devices to be used as boot disk. Hence the file system is visible from dom0 and domU the same way (at least RO from dom0). I might be wrong. Correct me if you think so.

Keep in mind, VMware and Xen are very different. VMware emulates a device. That device has state, I presume that they need to get their device into a well defined state. We don't have this problem as we can just detach and reattach all of the devices.

Of course, VMware is advantaged in that they use shadowing paging so they do not have any of the canonicalization problems that we have.

Regards,

Anthony Liguori

Quoted 5 lines
Signature · 4 lines
-- 
Jayesh
------------------------------------------------------------------------
Everything you can imagine is real 
#7 lore raw
In reply to Anthony Liguori
Quoted 10 lines · Anthony Liguori

Moreover, you cannot dump the state of a domain after a pause and expect it to ever run again.

Guests are aware of the physical addresses of the memory that's been allocated to them. Because of this, to save a domain's state in a restorable way you need the guest to "canonicalize" itself. The only way to do this today is through a suspend operation which happens to be a subop of shutdown. Shutdowns are non-recoverable so you cannot use this as a snapshotting mechanism.

Quoted 2 lines

I've gotten a lot of requests for light weight checkpointing. AFAIK, noone is actually working on it though.

Hi,

I've got this running for xenlinux, using self-checkpointing. I solve the canonicalization problem by having a radix-tree which maps mfns to offsets in the pfn->mfn table, and upon resume use this to remap all the page tables.

It works both across the network and to a block device, as long as it's opened with O_DIRECT.

I am working on bringing the patch up to date with Xen 3.0.2 at the moment. It would be great to have the driver model better support resume after suspend of xenbus and devices in the same domU.

Jacob

#8 lore raw
In reply to Ewan Mellor
Quoted 34 lines · Ewan Mellor
Quoted 4 lines · Jayesh Salvi

Hi,

Could anyone tell me, why 'xm save' has live parameter set to false by default. From yesterday's patch ([PATCH] [XenD] Migration-related

change)

Quoted 1 line

i guess this paramter is renamed to network.

This parameter has not been renamed -- the rename was for a similar flag passed in to the device migration code, but the live flag for migration remains.

Quoted 4 lines

[Snip]

I am interested in saving the state of a virtual machine to a file, but want to continue it running. I want to backup the state of the machine,

so

Quoted 2 lines

I want this to be unintrusive operation. I would like to pause the domU and save it to file but keeping it still in memory. After save to file

is

Quoted 4 lines

done I will unpause the domU.

I don't see why this shouldn't be possible if live migration works so well.

The reason it's not supported at the moment is this: if you take a snapshot of
a VM, then run for a bit, and then try and run the snapshot against the same
filesystem that you were using before, you will inevitably corrupt the filesystem.

Quoted 6 lines

If you had a way to snapshot the storage at the same time as the VM, then you
could make live snapshotting of VMs work properly. As it is, this is not integrated into Xend at the moment, and not supported because of the danger of
filesystem corruption if you don't know what you are doing.

OK. So as I understand it, we will need a snapshotting mechanism that does snapshot of storage and that of domU state in one single atomic operation. I will study the suspend, pause , migrate and shutdown semantics and see what would be the best to stop domU from modifying the disk "for a while" - during which we can have a consistent snapshot of storage. If nothing else works an explicit 'xm save' and behind the curtain 'xm restore' will do the job I guess - a bit intrusive solution it will be though.

If anyone has further ideas on this line, I am all ears.

Thanks!

Ewan.

Quoted 1 line

--
Jayesh
------------------------------------------------------------------------
Everything you can imagine is real

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel