libxl: Disallow save or migrate when host devices are assigned to a guest.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 6 lines · Konrad Rzeszutek Wilk
It is unhealthy. If the device is not doing any DMA operations it would work - but if you are saving and there are DMA operations happening the chance of corruption (outstanding DMAs) increase.
As such re-use the check migration used.
s/used// ?
Quoted 87 lines
Signed-off-by Konrad Rzeszutek Wilk <[email protected]>--- src/libxl/libxl_domain.c | 19 +++++++++++++++++++ src/libxl/libxl_domain.h | 3 +++ src/libxl/libxl_driver.c | 6 ++++++ src/libxl/libxl_migration.c | 15 +-------------- 4 files changed, 29 insertions(+), 14 deletions(-)src/libxl/libxl_domain.c +19
-0@@ -178,6 +178,25 @@ libxlDomainObjEndJob(libxlDriverPrivatePtr driver ATTRIBUTE_UNUSED,return virObjectUnref (obj); } +/* +* Checks whether the domain has host devices (PCIe) to disallow +* migration or saving of guest - unless they are detached. +* +* Returns true if the domain has host devices, otherwise false. +*/ +bool +libxlDomainHasHostDevices (virDomainDefPtr def) +{ +/* Migration is not allowed if definition contains any hostdevs */ +if (def->nhostdevs >0 ) { +virReportError (VIR_ERR_OPERATION_INVALID ,"%s" , +_ ("domain has assigned host devices" )); +return true; + } + +return false; +} +static void *libxlDomainObjPrivateAlloc (void ) {src/libxl/libxl_domain.h +3
-0@@ -95,6 +95,9 @@ char * libxlDomainManagedSavePath(libxlDriverPrivatePtr driver, virDomainObjPtr vm); +bool +libxlDomainHasHostDevices (virDomainDefPtr def); + int libxlDomainSaveImageOpen(libxlDriverPrivatePtr driver, libxlDriverConfigPtr cfg,src/libxl/libxl_driver.c +6
-0@@ -1650,6 +1650,9 @@ libxlDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml, goto endjob; } +if (libxlDomainHasHostDevices (vm->def)) + goto endjob; +if (libxlDoDomainSave (driver, vm, to) <0 ) goto endjob;@@ -1876,6 +1879,9 @@ libxlDomainManagedSave(virDomainPtr dom, unsigned int flags) goto endjob; } +if (libxlDomainHasHostDevices (vm->def)) + goto endjob; + name =libxlDomainManagedSavePath (driver, vm);if (name ==NULL ) goto endjob;src/libxl/libxl_migration.c +0
-3@@ -209,19 +209,6 @@ libxlDoMigrateSend(libxlDriverPrivatePtr driver,return ret; } -static bool -libxlDomainMigrationIsAllowed (virDomainDefPtr def) -{
src/libxl/libxl_migration.c libxlDoMigrateSend(libxlDriverPrivatePtr driver, · line 224
Quoted 10 lines
src/libxl/libxl_migration.c +0
-10-/* Migration is not allowed if definition contains any hostdevs */ -if (def->nhostdevs >0 ) { -virReportError (VIR_ERR_OPERATION_INVALID ,"%s" , -_ ("domain has assigned host devices" )); -return false; - } - -return true; -} -
This function was created with the intention of adding more checks, e.g. is the cpu and numa configuration migratable? Are there pending snapshot or block jobs (once those are supported)? ...
I'd like to keep libxlDomainMigrationIsAllowed even though it currently only checks for assigned hostdevs. I think it improves readability of the migration code. For the time it could simply call libxlDomainHasHostDevices.
Regards,
Jim
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 9 lines · Jim Fehlig
Quoted 6 lines · Konrad Rzeszutek Wilk
It is unhealthy. If the device is not doing any DMA operations it would work - but if you are saving and there are DMA operations happening the chance of corruption (outstanding DMAs) increase.
As such re-use the check migration used.
s/used// ?
<nods>
Quoted 103 lines
Quoted 88 lines
Signed-off-by Konrad Rzeszutek Wilk <[email protected]>--- src/libxl/libxl_domain.c | 19 +++++++++++++++++++ src/libxl/libxl_domain.h | 3 +++ src/libxl/libxl_driver.c | 6 ++++++ src/libxl/libxl_migration.c | 15 +-------------- 4 files changed, 29 insertions(+), 14 deletions(-)src/libxl/libxl_domain.c +19
-0@@ -178,6 +178,25 @@ libxlDomainObjEndJob(libxlDriverPrivatePtr driver ATTRIBUTE_UNUSED,return virObjectUnref (obj); } +/* +* Checks whether the domain has host devices (PCIe) to disallow +* migration or saving of guest - unless they are detached. +* +* Returns true if the domain has host devices, otherwise false. +*/ +bool +libxlDomainHasHostDevices (virDomainDefPtr def) +{ +/* Migration is not allowed if definition contains any hostdevs */ +if (def->nhostdevs >0 ) { +virReportError (VIR_ERR_OPERATION_INVALID ,"%s" , +_ ("domain has assigned host devices" )); +return true; + } + +return false; +} +static void *libxlDomainObjPrivateAlloc (void ) {src/libxl/libxl_domain.h +3
-0@@ -95,6 +95,9 @@ char * libxlDomainManagedSavePath(libxlDriverPrivatePtr driver, virDomainObjPtr vm); +bool +libxlDomainHasHostDevices (virDomainDefPtr def); + int libxlDomainSaveImageOpen(libxlDriverPrivatePtr driver, libxlDriverConfigPtr cfg,src/libxl/libxl_driver.c +6
-0@@ -1650,6 +1650,9 @@ libxlDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml, goto endjob; } +if (libxlDomainHasHostDevices (vm->def)) + goto endjob; +if (libxlDoDomainSave (driver, vm, to) <0 ) goto endjob;@@ -1876,6 +1879,9 @@ libxlDomainManagedSave(virDomainPtr dom, unsigned int flags) goto endjob; } +if (libxlDomainHasHostDevices (vm->def)) + goto endjob; + name =libxlDomainManagedSavePath (driver, vm);if (name ==NULL ) goto endjob;src/libxl/libxl_migration.c +0
-3@@ -209,19 +209,6 @@ libxlDoMigrateSend(libxlDriverPrivatePtr driver,return ret; } -static bool -libxlDomainMigrationIsAllowed (virDomainDefPtr def) -{src/libxl/libxl_migration.c libxlDoMigrateSend(libxlDriverPrivatePtr driver, · line 224
Quoted 10 lines
src/libxl/libxl_migration.c +0
-10-/* Migration is not allowed if definition contains any hostdevs */ -if (def->nhostdevs >0 ) { -virReportError (VIR_ERR_OPERATION_INVALID ,"%s" , -_ ("domain has assigned host devices" )); -return false; - } - -return true; -} -This function was created with the intention of adding more checks, e.g. is the cpu and numa configuration migratable? Are there pending snapshot or block jobs (once those are supported)? ...
Quoted 4 lines
I'd like to keep libxlDomainMigrationIsAllowed even though it currently only checks for assigned hostdevs. I think it improves readability of the migration code. For the time it could simply call libxlDomainHasHostDevices.
You got it.
Quoted 19 lines · Jim Fehlig
Review
Quoted 13 lines · Konrad Rzeszutek Wilk
(quoted diff) +0
-13-static bool -libxlDomainMigrationIsAllowed(virDomainDefPtr def) -{ - /* Migration is not allowed if definition contains any hostdevs */ - if (def->nhostdevs > 0) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain has assigned host devices")); - return false; - } - - return true; -} -This function was created with the intention of adding more checks, e.g. is the cpu and numa configuration migratable?
Only vaguely related to the patch, I know (sorry!), but if I can ask, what do you mean with "is the cpu and numa configuration migratable?"
I mean what NUMA configuration are we talking about, and when and under what circumstances would you consider it "migratable"?
Thanks and Regards,
Dario
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 24 lines · Dario Faggioli
Quoted 4 lines · Jim Fehlig
Konrad Rzeszutek Wilk wrote:
Quoted 18 lines
Quoted 4 lines
(quoted diff) +0
-3-static bool -libxlDomainMigrationIsAllowed(virDomainDefPtr def) -{Review
Quoted 10 lines
(quoted diff) +0
-10- /* Migration is not allowed if definition contains any hostdevs */ - if (def->nhostdevs > 0) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain has assigned host devices")); - return false; - } - - return true; -} -This function was created with the intention of adding more checks, e.g. is the cpu and numa configuration migratable?
Quoted 3 lines
Only vaguely related to the patch, I know (sorry!), but if I can ask, what do you mean with "is the cpu and numa configuration migratable?"
I was thinking about domXML such as
<domain>
...
<vcpu cpuset='0-8'>8</vcpu>
<memory>62914560</memory>
<maxMemory>104857600</maxMemory>
<numatune>
<memory mode='strict' nodeset='1-2'/>
</numatune> ...
</domain>
Quoted 3 lines
I mean what NUMA configuration are we talking about, and when and under what circumstances would you consider it "migratable"?
E.g. if a domain is configured to use memory allocated from certain numa nodes, we'd want to make sure the dest has sufficient memory amongst those nodes.
But these were just examples of things we may want to check before starting the migration. I suppose there are better examples wrt storage, e.g. does the domain have an attached DVD, ...
Regards,
Jim
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 10 lines · Jim Fehlig
Quoted 3 lines · Dario Faggioli
I mean what NUMA configuration are we talking about, and when and under what circumstances would you consider it "migratable"?
E.g. if a domain is configured to use memory allocated from certain numa nodes, we'd want to make sure the dest has sufficient memory amongst those nodes.
Right. I was asking because I'm interested in the problem at the libxl level. To the best of my knowledge, I don't think we do anything like that in libxl for now, and I still am not sure whether we should... :-)
Quoted 4 lines
But these were just examples of things we may want to check before starting the migration. I suppose there are better examples wrt storage, e.g. does the domain have an attached DVD, ...
Exactly.
Do (if you know that) other drivers in libvirt do these kind of checks?
Regards,
Dario
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 20 lines · Dario Faggioli
Quoted 4 lines · Jim Fehlig
Dario Faggioli wrote:
Quoted 9 lines
Quoted 4 lines
I mean what NUMA configuration are we talking about, and when and under what circumstances would you consider it "migratable"?
E.g. if a domain is configured to use memory allocated from certain numa nodes, we'd want to make sure the dest has sufficient memory amongst those nodes.
Right. I was asking because I'm interested in the problem at the libxl level. To the best of my knowledge, I don't think we do anything like that in libxl for now, and I still am not sure whether we should... :-)
Quoted 9 lines
Quoted 5 lines
But these were just examples of things we may want to check before starting the migration. I suppose there are better examples wrt storage, e.g. does the domain have an attached DVD, ...
Exactly.
Do (if you know that) other drivers in libvirt do these kind of checks?
Yes. The qemu driver has quite extensive migration checks.
Regards,
Jim
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 13 lines · Jim Fehlig
Quoted 12 lines · Dario Faggioli
Quoted 9 lines · Jim Fehlig
E.g. if a domain is configured to use memory allocated from certain numa nodes, we'd want to make sure the dest has sufficient memory amongst those nodes.
But these were just examples of things we may want to check before starting the migration. I suppose there are better examples wrt storage, e.g. does the domain have an attached DVD, ...
Quoted 5 lines
Quoted 2 lines
Do (if you know that) other drivers in libvirt do these kind of checks?
Yes. The qemu driver has quite extensive migration checks.
Interesting. I never had the chance to check that.
I think we should have a look and try to figure out whether some o them make sense for us too, and decide whether we want them in libxl or in libvirt.
I'm adding this to my TODO list.
Thanks and Regards,
Dario
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel