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 1226234 - No audit log when start a vm with memory device/hot-plug a memory device
Summary: No audit log when start a vm with memory device/hot-plug a memory device
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
medium
medium
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 1266078
TreeView+ depends on / blocked
 
Reported: 2015-05-29 09:31 UTC by Luyao Huang
Modified: 2015-11-19 06:39 UTC (History)
6 users (show)

Fixed In Version: libvirt-1.2.17-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1266078 (view as bug list)
Environment:
Last Closed: 2015-11-19 06:39:24 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2202 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2015-11-19 08:17:58 UTC

Description Luyao Huang 2015-05-29 09:31:22 UTC
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:

Comment 1 Peter Krempa 2015-07-01 08:25:42 UTC
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

Comment 3 Luyao Huang 2015-07-17 08:51:58 UTC
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.

Comment 4 Luyao Huang 2015-09-08 09:48:40 UTC
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 6 Luyao Huang 2015-10-08 09:49:20 UTC
Verify this bug with libvirt-1.2.17-12.el7.x86_64:

1. start a guest which have maxmemory:

# virsh start rhel7.0-rhel
Domain rhel7.0-rhel started

2. attach a memory device:

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

3. we can find a audit log:

# ausearch -ts today -m VIRT_RESOURCE | grep 'mem'
...
type=VIRT_RESOURCE msg=audit(1444297630.709:19955): pid=17359 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="rhel7.0-rhel" uuid=67c7a123-5415-4136-af62-a2ee098ba6cd old-mem=4048896 new-mem=4179968 exe="/usr/sbin/libvirtd" hostname=? addr=? terminal=? res=failed'

4. hot-unplug a memdevice:

# virsh detach-device rhel7.0-rhel memdevice.xml
Device detached successfully

5. we can find a audit log:

type=VIRT_RESOURCE msg=audit(1444297632.731:19956): pid=17359 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="rhel7.0-rhel" uuid=67c7a123-5415-4136-af62-a2ee098ba6cd old-mem=4179968 new-mem=4048896 exe="/usr/sbin/libvirtd" hostname=? addr=? terminal=? res=success'

Comment 8 errata-xmlrpc 2015-11-19 06:39:24 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/RHBA-2015-2202.html


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