You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "weizhouapache (via GitHub)" <gi...@apache.org> on 2024/06/11 08:09:51 UTC
[PR] kvm: replace ISO path in vm XML configuration during vm migration [cloudstack]
weizhouapache opened a new pull request, #9212:
URL: https://github.com/apache/cloudstack/pull/9212
### Description
This PR fixes #8901
steps to reproduce the issue
- create env with 2 image store
- create a vm
- register an ISO
- attach the ISO to the vm
- migrate the vm to another host
expected result: migration succeeds.
actually result: sometimes migration works, sometimes not
<!--- Describe your changes in DETAIL - And how has behaviour functionally changed. -->
<!-- For new features, provide link to FS, dev ML discussion etc. -->
<!-- In case of bug fix, the expected and actual behaviours, steps to reproduce. -->
<!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be closed when this PR gets merged -->
<!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" -->
<!-- Fixes: # -->
<!--- ******************************************************************************* -->
<!--- NOTE: AUTOMATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE DOCUMENTATION. -->
<!--- PLEASE PUT AN 'X' in only **ONE** box -->
<!--- ******************************************************************************* -->
### Types of changes
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] Enhancement (improves an existing feature and functionality)
- [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
- [ ] build/CI
### Feature/Enhancement Scale or Bug Severity
#### Feature/Enhancement Scale
- [ ] Major
- [ ] Minor
#### Bug Severity
- [ ] BLOCKER
- [ ] Critical
- [ ] Major
- [ ] Minor
- [ ] Trivial
### Screenshots (if appropriate):
### How Has This Been Tested?
<!-- Please describe in detail how you tested your changes. -->
<!-- Include details of your testing environment, and the tests you ran to -->
#### How did you try to break this feature and the system with this change?
<!-- see how your change affects other areas of the code, etc. -->
<!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) document -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] kvm: replace ISO path in vm XML configuration during vm migration [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #9212:
URL: https://github.com/apache/cloudstack/pull/9212#issuecomment-2160906191
@weizhouapache a [SL] Trillian-Jenkins test job (rocky8 mgmt + kvm-rocky8) has been kicked to run smoke tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] kvm: replace ISO path in vm XML configuration during vm migration [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #9212:
URL: https://github.com/apache/cloudstack/pull/9212#issuecomment-2160620543
@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] kvm: replace ISO path in vm XML configuration during vm migration [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #9212:
URL: https://github.com/apache/cloudstack/pull/9212#issuecomment-2162063718
<b>[SF] Trillian test result (tid-10414)</b>
Environment: kvm-rocky8 (x2), Advanced Networking with Mgmt server r8
Total time taken: 47174 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr9212-t10414-kvm-rocky8.zip
Smoke tests completed. 130 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:
Test | Result | Time (s) | Test File
--- | --- | --- | ---
test_02_trigger_shutdown | `Failure` | 336.54 | test_safe_shutdown.py
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] kvm: replace ISO path in vm XML configuration during vm migration [cloudstack]
Posted by "shwstppr (via GitHub)" <gi...@apache.org>.
shwstppr commented on code in PR #9212:
URL: https://github.com/apache/cloudstack/pull/9212#discussion_r1634657512
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java:
##########
@@ -175,6 +178,12 @@ Use VIR_DOMAIN_XML_SECURE (value = 1) prior to v1.0.0.
s_logger.debug(String.format("Replaced disk mount point [%s] with [%s] in VM [%s] XML configuration. New XML configuration is [%s].", oldIsoVolumePath, newIsoVolumePath, vmName, xmlDesc));
}
}
+
+ // Replace CDROM ISO path
+ String oldCdromIsoPath = getOldVolumePathForCdrom(disks, vmName);
+ String newCdromIsoPath = getNewVolumePathForCdrom(libvirtComputingResource, conn, to);
+ xmlDesc = replaceCdromIsoPath(xmlDesc, vmName, oldCdromIsoPath, newCdromIsoPath);
Review Comment:
Do we need any check if both old and new ISO path are same?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] kvm: replace ISO path in vm XML configuration during vm migration [cloudstack]
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on code in PR #9212:
URL: https://github.com/apache/cloudstack/pull/9212#discussion_r1634499005
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java:
##########
@@ -702,6 +711,81 @@ private String getNewVolumePathIfDatastoreHasChanged(LibvirtComputingResource li
return newIsoVolumePath;
}
+ private String getOldVolumePathForCdrom(List<DiskDef> disks, String vmName) {
+ String oldIsoVolumePath = null;
+ for (DiskDef disk : disks) {
+ if (DiskDef.DeviceType.CDROM.equals(disk.getDeviceType())
+ && CDROM_LABEL.equals(disk.getDiskLabel())
+ && disk.getDiskPath() != null) {
+ oldIsoVolumePath = disk.getDiskPath();
+ break;
+ }
+ }
+ return oldIsoVolumePath;
+ }
+
+ private String getNewVolumePathForCdrom(LibvirtComputingResource libvirtComputingResource, Connect conn, VirtualMachineTO to) throws LibvirtException, URISyntaxException {
+ DiskTO newDisk = null;
+ for (DiskTO disk : to.getDisks()) {
+ DataTO data = disk.getData();
+ if (disk.getDiskSeq() == 3 && data != null && data.getPath() != null) {
+ newDisk = disk;
+ break;
+ }
+ }
+
+ String newIsoVolumePath = null;
+ if (newDisk != null) {
+ newIsoVolumePath = libvirtComputingResource.getVolumePath(conn, newDisk);
+ }
+ return newIsoVolumePath;
+ }
+
+ protected String replaceCdromIsoPath(String xmlDesc, String vmName, String oldIsoVolumePath, String newIsoVolumePath) throws IOException, ParserConfigurationException, TransformerException, SAXException {
Review Comment:
right, it is complex ..
the other replacements in same java file use the similar way ...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] kvm: replace ISO path in vm XML configuration during vm migration [cloudstack]
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on code in PR #9212:
URL: https://github.com/apache/cloudstack/pull/9212#discussion_r1634505797
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java:
##########
@@ -175,6 +178,12 @@ Use VIR_DOMAIN_XML_SECURE (value = 1) prior to v1.0.0.
s_logger.debug(String.format("Replaced disk mount point [%s] with [%s] in VM [%s] XML configuration. New XML configuration is [%s].", oldIsoVolumePath, newIsoVolumePath, vmName, xmlDesc));
}
}
+
+ // Replace CDROM ISO path
+ String oldCdromIsoPath = getOldVolumePathForCdrom(disks, vmName);
+ String newCdromIsoPath = getNewVolumePathForCdrom(libvirtComputingResource, conn, to);
+ xmlDesc = replaceCdromIsoPath(xmlDesc, vmName, oldCdromIsoPath, newCdromIsoPath);
Review Comment:
@shwstppr
my original thought is actually same as it :-D
at the end I decided to implement the same as other replacements.
it looks complex, but in my testing it took only around 0.01 second.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] kvm: replace ISO path in vm XML configuration during vm migration [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on code in PR #9212:
URL: https://github.com/apache/cloudstack/pull/9212#discussion_r1634429792
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java:
##########
@@ -702,6 +711,81 @@ private String getNewVolumePathIfDatastoreHasChanged(LibvirtComputingResource li
return newIsoVolumePath;
}
+ private String getOldVolumePathForCdrom(List<DiskDef> disks, String vmName) {
+ String oldIsoVolumePath = null;
+ for (DiskDef disk : disks) {
+ if (DiskDef.DeviceType.CDROM.equals(disk.getDeviceType())
+ && CDROM_LABEL.equals(disk.getDiskLabel())
+ && disk.getDiskPath() != null) {
+ oldIsoVolumePath = disk.getDiskPath();
+ break;
+ }
+ }
+ return oldIsoVolumePath;
+ }
+
+ private String getNewVolumePathForCdrom(LibvirtComputingResource libvirtComputingResource, Connect conn, VirtualMachineTO to) throws LibvirtException, URISyntaxException {
+ DiskTO newDisk = null;
+ for (DiskTO disk : to.getDisks()) {
+ DataTO data = disk.getData();
+ if (disk.getDiskSeq() == 3 && data != null && data.getPath() != null) {
+ newDisk = disk;
+ break;
+ }
+ }
+
+ String newIsoVolumePath = null;
+ if (newDisk != null) {
+ newIsoVolumePath = libvirtComputingResource.getVolumePath(conn, newDisk);
+ }
+ return newIsoVolumePath;
+ }
+
+ protected String replaceCdromIsoPath(String xmlDesc, String vmName, String oldIsoVolumePath, String newIsoVolumePath) throws IOException, ParserConfigurationException, TransformerException, SAXException {
Review Comment:
wow, I hope we never have to change this method ever again... the complexity of it is a bit much but the code looks good.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] kvm: replace ISO path in vm XML configuration during vm migration [cloudstack]
Posted by "shwstppr (via GitHub)" <gi...@apache.org>.
shwstppr commented on code in PR #9212:
URL: https://github.com/apache/cloudstack/pull/9212#discussion_r1634451600
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java:
##########
@@ -175,6 +178,12 @@ Use VIR_DOMAIN_XML_SECURE (value = 1) prior to v1.0.0.
s_logger.debug(String.format("Replaced disk mount point [%s] with [%s] in VM [%s] XML configuration. New XML configuration is [%s].", oldIsoVolumePath, newIsoVolumePath, vmName, xmlDesc));
}
}
+
+ // Replace CDROM ISO path
+ String oldCdromIsoPath = getOldVolumePathForCdrom(disks, vmName);
+ String newCdromIsoPath = getNewVolumePathForCdrom(libvirtComputingResource, conn, to);
+ xmlDesc = replaceCdromIsoPath(xmlDesc, vmName, oldCdromIsoPath, newCdromIsoPath);
Review Comment:
@weizhouapache it could be a wild idea but a simple string replace oldpath to newpath won't work?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] kvm: replace ISO path in vm XML configuration during vm migration [cloudstack]
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on PR #9212:
URL: https://github.com/apache/cloudstack/pull/9212#issuecomment-2160616242
@blueorangutan package
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] kvm: replace ISO path in vm XML configuration during vm migration [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #9212:
URL: https://github.com/apache/cloudstack/pull/9212#issuecomment-2160805273
Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9869
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] kvm: replace ISO path in vm XML configuration during vm migration [cloudstack]
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on code in PR #9212:
URL: https://github.com/apache/cloudstack/pull/9212#discussion_r1634741701
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java:
##########
@@ -175,6 +178,12 @@ Use VIR_DOMAIN_XML_SECURE (value = 1) prior to v1.0.0.
s_logger.debug(String.format("Replaced disk mount point [%s] with [%s] in VM [%s] XML configuration. New XML configuration is [%s].", oldIsoVolumePath, newIsoVolumePath, vmName, xmlDesc));
}
}
+
+ // Replace CDROM ISO path
+ String oldCdromIsoPath = getOldVolumePathForCdrom(disks, vmName);
+ String newCdromIsoPath = getNewVolumePathForCdrom(libvirtComputingResource, conn, to);
+ xmlDesc = replaceCdromIsoPath(xmlDesc, vmName, oldCdromIsoPath, newCdromIsoPath);
Review Comment:
@shwstppr
yes, let me add it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] kvm: replace ISO path in vm XML configuration during vm migration [cloudstack]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #9212:
URL: https://github.com/apache/cloudstack/pull/9212#issuecomment-2160092629
## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/9212?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 4.30%. Comparing base [(`4bd0b1c`)](https://app.codecov.io/gh/apache/cloudstack/commit/4bd0b1c24f12251c99b9fc3818add4bebd367258?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`da32758`)](https://app.codecov.io/gh/apache/cloudstack/commit/da327585422216274ec52284b81f532a9f50b83e?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## 4.19 #9212 +/- ##
============================================
- Coverage 14.96% 4.30% -10.66%
============================================
Files 5373 363 -5010
Lines 469303 29311 -439992
Branches 61048 5118 -55930
============================================
- Hits 70215 1261 -68954
+ Misses 391314 27907 -363407
+ Partials 7774 143 -7631
```
| [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/9212/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [uitests](https://app.codecov.io/gh/apache/cloudstack/pull/9212/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `4.30% <ø> (ø)` | |
| [unittests](https://app.codecov.io/gh/apache/cloudstack/pull/9212/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/cloudstack/pull/9212?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] kvm: replace ISO path in vm XML configuration during vm migration [cloudstack]
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on PR #9212:
URL: https://github.com/apache/cloudstack/pull/9212#issuecomment-2160904518
@blueorangutan test rocky8 kvm-rocky8
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] kvm: replace ISO path in vm XML configuration during vm migration [cloudstack]
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on PR #9212:
URL: https://github.com/apache/cloudstack/pull/9212#issuecomment-2163089437
> LGTM based on manual testing. I cannot reproduce the problem after this patch.
thanks @vladimirpetrov !
merging
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] kvm: replace ISO path in vm XML configuration during vm migration [cloudstack]
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache merged PR #9212:
URL: https://github.com/apache/cloudstack/pull/9212
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org