Skip to content

kvm: set LIBVIRTD_ARGS so libvirtd listens on Debian and Ubuntu hosts - #14153

Open
nagaboinaramgopal wants to merge 1 commit into
apache:4.20from
nagaboinaramgopal:fix/kvm-libvirtd-listen-args
Open

kvm: set LIBVIRTD_ARGS so libvirtd listens on Debian and Ubuntu hosts#14153
nagaboinaramgopal wants to merge 1 commit into
apache:4.20from
nagaboinaramgopal:fix/kvm-libvirtd-listen-args

Conversation

@nagaboinaramgopal

Copy link
Copy Markdown
Contributor

Description

cloudstack-setup-agent sets up live migration on Debian and Ubuntu by writing libvirtd_opts='-l' to /etc/default/libvirtd and masking the libvirtd sockets. The libvirtd.service unit on current releases reads LIBVIRTD_ARGS from that file instead (Debian 12 and 13: ExecStart=/usr/sbin/libvirtd $LIBVIRTD_ARGS with --timeout 120 as the default), so after adding a host libvirtd runs without --listen, nothing listens on 16509/16514 and live migration fails. This also sets LIBVIRTD_ARGS="--listen", and keeps libvirtd_opts for older units that still read it.

Related: #9802 and #12374.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • 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
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

N/A

How Has This Been Tested?

Live tested on two fresh Debian 13 KVM hosts (libvirt 11.3, QEMU 10.0) added to a cluster with addHost, with NFS primary storage, and a VM live migrated between them with migrateVirtualMachine.

Before this change, right after addHost:

/etc/default/libvirtd   libvirtd_opts='-l'
libvirtd process        /usr/sbin/libvirtd --timeout 120
ports 16509/16514       nothing listening

15:51:27 GET command=migrateVirtualMachine&virtualmachineid=...&hostid=...
15:51:28 ERROR [LibvirtMigrateCommandWrapper] Can't migrate domain due to: [unable to connect to server at '<destination host>:16509': Connection refused]
15:51:28 Complete async job-1640, jobStatus: FAILED, resultCode: 530, "Failed to migrate domain"

With this change, same hosts reset to the distro defaults and added again:

/etc/default/libvirtd   libvirtd_opts='-l'
                        LIBVIRTD_ARGS="--listen"
libvirtd process        /usr/sbin/libvirtd --listen
port 16514              listening

15:58:25 GET command=migrateVirtualMachine&virtualmachineid=...&hostid=...
15:58:28 Complete async job-1653, jobStatus: SUCCEEDED

Debian 12 (libvirt 9.0) uses the same unit layout.

How did you try to break this feature and the system with this change?

Older units that read libvirtd_opts still get it. replace_or_add_line replaces an existing or commented LIBVIRTD_ARGS line, so adding a host again does not duplicate it. The RHEL and SUSE paths are unchanged.

cloudstack-setup-agent sets up live migration on Debian and Ubuntu by
writing libvirtd_opts='-l' to /etc/default/libvirtd and masking the libvirtd
sockets. The libvirtd.service unit on current releases reads LIBVIRTD_ARGS
from that file instead (Debian 12 and 13 run "libvirtd $LIBVIRTD_ARGS" with
"--timeout 120" as the default), so after adding a host libvirtd runs
without --listen, nothing listens on the migration ports and live migration
fails with "unable to connect to server". Also set LIBVIRTD_ARGS="--listen",
and keep libvirtd_opts for older units that still read it.

@weizhouapache weizhouapache left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm

we have not faced this issue in Trillian tests, as we have already applied it via ansible

- name: Update /etc/default/libvirtd in Ubuntu 22.04
  lineinfile:
    dest: "/etc/default/libvirtd"
    regexp: '^LIBVIRTD_ARGS=*'
    line: 'LIBVIRTD_ARGS="-l"'
  when: ansible_distribution_version is version('22.04','>=')

@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 16.38%. Comparing base (8261bec) to head (e31f9a0).

Additional details and impacted files
@@             Coverage Diff              @@
##               4.20   #14153      +/-   ##
============================================
- Coverage     16.38%   16.38%   -0.01%     
+ Complexity    13615    13614       -1     
============================================
  Files          5669     5669              
  Lines        501561   501561              
  Branches      60922    60922              
============================================
- Hits          82168    82167       -1     
- Misses       410185   410186       +1     
  Partials       9208     9208              
Flag Coverage Δ
uitests 4.16% <ø> (ø)
unittests 17.24% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants