Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-20807

The default path match pattern for guest agent is problematic.

    • libvirt-10.0.0-1.el9
    • None
    • Low
    • sst_virtualization
    • ssg_virtualization
    • 26
    • None
    • QE ack, Dev ack
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • Unspecified
    • 10.0.0
    • None

      What were you trying to do that didn't work?

      I set a customized source path for guest agent, and found it get ignored by libvirt.

      Please provide the package NVR for which bug is seen:

      libvirt-9.10.0-1.el9.x86_64

      How reproducible:

      100%

      Steps to reproduce

      1. Define a vm with customized source path for guest agent
        <channel type="unix">
          <source mode="bind" path="/40-a/org.qemu.guest_agent.0"/>
          <target type="virtio" name="org.qemu.guest_agent.0"/>
        </channel>
        
      1. Check vm dumpxml
        # virsh dumpxml vm2 --xpath //channel
        <channel type="unix">
          <target type="virtio" name="org.qemu.guest_agent.0"/>
          <address type="virtio-serial" controller="0" bus="0" port="1"/>
        </channel>
        
      1. Try other paths:
        1) /tmp/40-aa/org.qemu.guest_agent.0 ==> ignored by libvirt
        2) /tmp/libvirt/qemu/channel/40-aa/org.qemu.guest_agent.0 ==> ignored by libvirt
        3) /tmp/org.qemu.guest_agent.0 ==> not ignored by libvirt
        4) /run/libvirt/qemu/channel/2-vm2/org.qemu.guest_agent.0 ==> ignored by libvirt, expected

      Expected results

      The following path won't be ignored by libvirt:
      /40-a/org.qemu.guest_agent.0
      /tmp/40-aa/org.qemu.guest_agent.0
      /tmp/libvirt/qemu/channel/40-aa/org.qemu.guest_agent.0
      /tmp/org.qemu.guest_agent.0 (this one has got expected result)

      Actual results

      As above.

      Additional info

      I had a try on https://regex101.com/, I think this can be fixed by adding a "(" and ")" in the pattern.

       5438 static bool
       5439 qemuDomainChrMatchDefaultPath(const char *prefix,
       5440                               const char *infix,
       5441                               const char *target,
       5442                               const char *path)
       5443 {
       5444     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
       5445     g_autofree char *regexp = NULL;
       5446  
       5447     virBufferEscapeRegex(&buf, "^%s", prefix);
       5448     if (infix)                                                                                                                              
       5449         virBufferEscapeRegex(&buf, "%s", infix);
      -  5450   virBufferAddLit(&buf, "/(target/)?([^/]+\\.)|(domain-[^/]+/)|([0-9]+-[^/]+/)"); 
      +  5450   virBufferAddLit(&buf, "/(target/)?(([^/]+\\.)|(domain-[^/]+/)|([0-9]+-[^/]+/))");
       5451     virBufferEscapeRegex(&buf, "%s$", target);
       5452  
       5453     regexp = virBufferContentAndReset(&buf);
       5454  
       5455     return virStringMatch(path, regexp);
       5456 }
      

            mprivozn@redhat.com Michal Privoznik
            rhn-support-fjin Fangge Jin
            Yingshun Cui
            virt-maint virt-maint
            Fangge Jin Fangge Jin
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: