weizhouapache commented on pull request #3724:
URL: https://github.com/apache/cloudstack/pull/3724#issuecomment-881239648


   @slavkap @nvazquez 
   I believe this pr is good.
   
   Unfortunately when I tested on ubuntu 20.04, it fails.
   
   the reason is, ubuntu 20.04 uses -blockdev instead -device when start a vm 
via libvirt.
   ```
   # on ubuntu 20.04
   # virsh qemu-monitor-command i-2-85-VM '{"execute":"query-block"}' --pretty 
|jq -r ".return[].device"
   
   ```
   same issue as 
http://qemu.11.n7.nabble.com/query-block-command-is-missing-device-name-Deprecated-td714506.html
   I tried with code change below, still does not work
   ```
   diff --git 
a/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/qemu/QemuCommand.java
 
b/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/qemu/QemuCommand.java
   index 8461d31f08..6766291eaf 100644
   --- 
a/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/qemu/QemuCommand.java
   +++ 
b/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/qemu/QemuCommand.java
   @@ -57,6 +57,9 @@ public class QemuCommand {
                        if (arr.get(i).getAsJsonObject().has("inserted") && 
arr.get(i).getAsJsonObject().get("inserted").isJsonObject()) {
                            JsonObject inserted = 
arr.get(i).getAsJsonObject().get("inserted").getAsJsonObject();
                            if 
(inserted.get("file").getAsString().contains(path)) {
   +                            if 
(org.apache.commons.lang.StringUtils.isBlank(deviceName)) {
   +                                return 
inserted.get("node-name").getAsString();
   +                            }
                                return deviceName;
                            }
                        }
   ```
   
   on centos7 it works.
   
   ```
   # on centos
   # virsh qemu-monitor-command i-2-5-VM '{"execute":"query-block"}' --pretty 
|jq -r '.return[].device'
   drive-virtio-disk0
   drive-ide0-1-0
   ```
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to