RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1266078 - Audit log entries for hot(un)plugged memory devices are sometimes incorrect
Summary: Audit log entries for hot(un)plugged memory devices are sometimes incorrect
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.2
Hardware: x86_64
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On: 1226234
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-09-24 12:27 UTC by Peter Krempa
Modified: 2016-11-03 18:25 UTC (History)
6 users (show)

Fixed In Version: libvirt-1.3.1-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of: 1226234
Environment:
Last Closed: 2016-11-03 18:25:15 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:2577 0 normal SHIPPED_LIVE Moderate: libvirt security, bug fix, and enhancement update 2016-11-03 12:07:06 UTC

Description Peter Krempa 2015-09-24 12:27:33 UTC
+++ This bug was initially created as a clone of Bug #1226234 +++

Description of problem:
No audit log when start a vm with memory device/hot-plug a memory device

Version-Release number of selected component (if applicable):

libvirt-1.2.15-2.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Make sure auditing is enabled

2.hot-plug a memory device
# cat memdevice.xml 
    <memory model='dimm'>
      <source>
        <pagesize unit='KiB'>4</pagesize>
        <nodemask>0</nodemask>
      </source>
      <target>
        <size unit='m'>512</size>
        <node>0</node>
      </target>
    </memory>

# virsh attach-device rhel7.0 memdevice.xml 
Device attached successfully

3.check the audit log
# ausearch -ts today -m VIRT_RESOURCE | grep 'mem'
(no log for memory deivce)

Actual results:
No audit log when start a vm with memory device/hot-plug a memory device

Expected results:
As host memory is a part of source and i notice libvirt will log the memory change, so i think libvirt should provide auditing of memory device resources

Additional info:

--- Additional comment from Peter Krempa on 2015-07-01 10:25:42 CEST ---

Fixed upstream:

commit 91081979dd3e33f2e39e3de234e52d0e69ffcccb
Author: Peter Krempa <pkrempa>
Date:   Fri Jun 26 17:14:33 2015 +0200

    qemu: Audit memory size with memory hotplug operations
    
    The memory device hot(un)plug was missing calls to the auditing code.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1226234

commit 1a1367746076f09d22cd1952673bcd4e0dbb6582
Author: Peter Krempa <pkrempa>
Date:   Fri Jun 26 17:12:39 2015 +0200

    conf: audit: Audit physical memory size rather than balloon request
    
    Since the balloon driver does not guarantee that it returns memory to
    the host, using the value in the audit message is not a good idea.
    
    This patch removes auditing from updating the balloon size and reports
    the total physical size at startup.

v1.2.17-rc2-7-g9108197

--- Additional comment from Luyao Huang on 2015-07-17 10:51:58 CEST ---

Hi peter,

I found the result is not right in libvirt-1.2.17-2.el7.x86_64:


# virsh attach-device r7 memdevice.xml
Device attached successfully

# ausearch -ts today -m VIRT_RESOURCE | grep 'mem'
type=VIRT_RESOURCE msg=audit(1437119640.335:14164): pid=18439 uid=0 auid=0 ses=3 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='virt=kvm resrc=mem reason=start vm="r7" uuid=9fedda95-4479-44c6-9feb-7ceee69e1669 old-mem=0 new-mem=1024000 exe="/usr/sbin/libvirtd" hostname=? addr=? terminal=pts/2 res=success'
type=VIRT_RESOURCE msg=audit(1437119753.401:14169): pid=18439 uid=0 auid=0 ses=3 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='virt=kvm resrc=mem reason=update vm="r7" uuid=9fedda95-4479-44c6-9feb-7ceee69e1669 old-mem=1024000 new-mem=1548288 exe="/usr/sbin/libvirtd" hostname=? addr=? terminal=pts/2 res=failed'

Although hot-plug is success, audit log show it is failed, and if i test a failed case, i cannot get any log:

# virsh attach-device r7 memdevice.xml
error: Failed to attach device from memdevice.xml
error: internal error: unable to execute QEMU command 'device_add': backend memory size must be multiple of 0x200000

# ausearch -ts recent -m VIRT_RESOURCE | grep 'mem'
<no matches>

Would you please help to check out? Thanks a lot for your help.

--- Additional comment from Luyao Huang on 2015-09-08 11:48:40 CEST ---

Hi peter,

I had sent mail to upstream to have a try to improve it:

https://www.redhat.com/archives/libvir-list/2015-August/msg00581.html

And Upstream commit:

commit 8f8031df1998725ac34a9a3138705c4f7cdf0488
Author: Luyao Huang <lhuang>
Date:   Thu Aug 13 22:15:28 2015 +0800

    qemu: Emit correct audit message for memory hot unplug

commit cb1fbda4a1b23581ed9e305a48b0376633d5ff4a
Author: Luyao Huang <lhuang>
Date:   Thu Aug 13 22:15:27 2015 +0800

    qemu: Emit correct audit message for memory hot plug

Comment 1 Peter Krempa 2015-09-24 12:28:23 UTC
$ git desc 8f8031df1998725ac34a9a3138705c4f7cdf0488
v1.2.19-rc1

Comment 3 Luyao Huang 2016-06-01 09:05:03 UTC
Verify this bug with libvirt-1.3.4-1.el7.x86_64:

1. test hot-plug success:

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 57    rhel72-test                    running

# cat memdevice1G.xml
    <memory model='dimm'>
      <target>
        <size unit='G'>1</size>
        <node>0</node>
      </target>
    </memory>

# virsh dominfo rhel72-test
Id:             57
Name:           rhel72-test
UUID:           855670a9-34e6-4da2-a1ec-1993de100d79
OS Type:        hvm
State:          running
CPU(s):         10
CPU time:       61.0s
Max memory:     4194304 KiB
Used memory:    2145728 KiB
Persistent:     yes
Autostart:      disable
Managed save:   no
Security model: selinux
Security DOI:   0
Security label: system_u:system_r:svirt_t:s0:c735,c1014 (permissive)


# virsh attach-device rhel72-test memdevice1G.xml 
Device attached successfully

# virsh dominfo rhel72-test
Id:             57
Name:           rhel72-test
UUID:           855670a9-34e6-4da2-a1ec-1993de100d79
OS Type:        hvm
State:          running
CPU(s):         10
CPU time:       73.3s
Max memory:     5242880 KiB
Used memory:    3194304 KiB
Persistent:     yes
Autostart:      disable
Managed save:   no
Security model: selinux
Security DOI:   0
Security label: system_u:system_r:svirt_t:s0:c735,c1014 (permissive)


# ausearch -ts recent -m VIRT_RESOURCE | grep 'mem'
type=VIRT_RESOURCE msg=audit(1464770792.893:26047): pid=8698 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:virtd_t:s0-s0:c0.c1023 msg='virt=kvm resrc=mem reason=start vm="rhel72-test" uuid=855670a9-34e6-4da2-a1ec-1993de100d79 old-mem=0 new-mem=4194304 exe="/usr/sbin/libvirtd" hostname=? addr=? terminal=? res=success'
type=VIRT_RESOURCE msg=audit(1464770836.216:26050): pid=8698 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:virtd_t:s0-s0:c0.c1023 msg='virt=kvm resrc=mem reason=update vm="rhel72-test" uuid=855670a9-34e6-4da2-a1ec-1993de100d79 old-mem=4194304 new-mem=5242880 exe="/usr/sbin/libvirtd" hostname=? addr=? terminal=? res=success'

2. test hot-plug fail:

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 57    rhel72-test                    running

# cat memdevice0.xml
    <memory model='dimm'>
      <target>
        <size unit='G'>0</size>
        <node>0</node>
      </target>
    </memory>


# virsh attach-device rhel72-test memdevice0.xml
error: Failed to attach device from memdevice0.xml
error: internal error: unable to execute QEMU command 'object-add': Property 'memory-backend-ram.size' doesn't take value '0'

# ausearch -ts recent -m VIRT_RESOURCE | grep 'mem'
...
type=VIRT_RESOURCE msg=audit(1464771123.151:26051): pid=8698 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:virtd_t:s0-s0:c0.c1023 msg='virt=kvm resrc=mem reason=update vm="rhel72-test" uuid=855670a9-34e6-4da2-a1ec-1993de100d79 old-mem=5242880 new-mem=5242880 exe="/usr/sbin/libvirtd" hostname=? addr=? terminal=? res=failed'

3. test hot-unplug success:


# virsh list --all
 Id    Name                           State
----------------------------------------------------
 57    rhel72-test                    running

# cat memdevice3.xml
    <memory model='dimm'>
      <target>
        <size unit='KiB'>131072</size>
        <node>0</node>
      </target>
    </memory>

# virsh attach-device rhel72-test memdevice3.xml 
Device attached successfully

# virsh detach-device rhel72-test memdevice3.xml 
Device detached successfully

# ausearch -ts recent -m VIRT_RESOURCE | grep 'mem'
...
type=VIRT_RESOURCE msg=audit(1464771788.700:26089): pid=8698 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:virtd_t:s0-s0:c0.c1023 msg='virt=kvm resrc=mem reason=update vm="rhel72-test" uuid=855670a9-34e6-4da2-a1ec-1993de100d79 old-mem=5242880 new-mem=5373952 exe="/usr/sbin/libvirtd" hostname=? addr=? terminal=? res=success'
type=VIRT_RESOURCE msg=audit(1464771802.020:26090): pid=8698 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:virtd_t:s0-s0:c0.c1023 msg='virt=kvm resrc=mem reason=update vm="rhel72-test" uuid=855670a9-34e6-4da2-a1ec-1993de100d79 old-mem=5373952 new-mem=5242880 exe="/usr/sbin/libvirtd" hostname=? addr=? terminal=? res=success'

Comment 5 errata-xmlrpc 2016-11-03 18:25:15 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2016-2577.html


Note You need to log in before you can comment on or make changes to this bug.