Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 884923

Summary: set_link can not change virtio NIC default display status in 'info qtree'
Product: Red Hat Enterprise Linux 6 Reporter: FuXiangChun <xfu>
Component: qemu-kvmAssignee: Virtualization Maintenance <virt-maint>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.4CC: acathrow, bsarathy, dyasny, juzhang, lersek, michen, mkenneth, pbonzini, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-12-07 10:31:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description FuXiangChun 2012-12-07 03:05:35 UTC
Description of problem:
1.boot guest with .....-device virtio-net-pci,netdev=hostnet1,mac=00:12:1a:21:62:02,bus=pci.0,addr=0x3,id=virtio-net-pci1,status=off. then use 'info qtree' to check it's display status.
info qtree:
......
dev-prop: status = off
.....

2.execute 'set_link virtio-net-pci1 on' in monitor. re-check it's status via 'info qtree', still is off status in 'info qree'

info qtree:
......
dev-prop: status = off
..... 

Additional:
rhel and windows guest have the same issue.

Version-Release number of selected component (if applicable):
# uname -r
2.6.32-345.el6.x86_64
qemu-kvm-0.12.1.2-2.337.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1..boot guest with .....-device virtio-net-pci,netdev=hostnet1,mac=00:12:1a:21:62:02,bus=pci.0,addr=0x3,id=virtio-net-pci1,status=off

2.check virtio NIC display status via info qtree
dev-prop: status = off

3.change virtio NIC in monitor 
  set_link virtio-net-pci1 on

4. re-check virtio NIC display status via info qtree
 dev-prop: status = off

Actual results:
set_link cannot change NIC display status.

Expected results:
after step3, virtio NIC display status:
dev-prop: status = on

Additional info:

Comment 2 Laszlo Ersek 2012-12-07 09:51:47 UTC
I think this is a device property issue. I tested it with a normally booted RHEL-6.3 guest (ie. no status=off on the qemu command line). "set_link net0 off/on" works OK functionally: the network vanishes and then returns in the guest. However the "info qtree" command in fact displays a wrong value while the link is down:

virsh # qemu-monitor-command fw-seabios63.g-rhel63.e-rhel63 --hmp --cmd info qtree
      dev: virtio-net-pci, id "net0"
        dev-prop: status = on

Comment 3 Laszlo Ersek 2012-12-07 10:31:27 UTC
do_info_qtree [hw/qdev.c]
  qbus_print(main_system_bus)
    qdev_print()
      qdev_print_props() -- for device (dev / bus / parent bus props)
      qbus_print() -- recursive call for each child bus

"dev" is a DeviceState here, "status" is contained in "dev->info->props"

hw/virtio-net.h:

#define DEFINE_VIRTIO_NET_FEATURES(_state, _field) \
  [...]
  DEFINE_PROP_BIT("status", _state, _field, VIRTIO_NET_F_STATUS, true), \
  [...]

hw/virtio-pci.c:

        .qdev.name  = "virtio-net-pci",
            DEFINE_VIRTIO_NET_FEATURES(VirtIOPCIProxy, host_features),

hw/qdev.h:

#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) {  \
        .name      = (_name),                                    \
        .info      = &(qdev_prop_bit),                           \
        .bitnr    = (_bit),                                      \
        .offset    = offsetof(_state, _field)                    \
            + type_check(uint32_t,typeof_field(_state, _field)), \
        .defval    = (bool[]) { (_defval) },                     \
        }

So the "status" qdev property corresponds to the VIRTIO_NET_F_STATUS bit of "VirtIOPCIProxy.host_features".

This bit is not about link state -- it is unrelated to the "set_link" command. Instead, this bit describes a host feature and partakes in host-guest feature negotiation. From the virtio-0.9.5 specification:

    If the VIRTIO_NET_F_STATUS feature bit is negotiated, the link sta-
    tus can be read from the bottom bit of the "status" config field.
    Otherwise, the link should be assumed active.

That is,
- "status = on" means: the guest can inquire about the link status,
- "status = off" means: the guest can *not* inquire about the link status,
  it must assume the link is always on.

(Side point:

It looks to me like the "status = off" case is not even supported. Namely, the virtio spec also says about virtio-net's device-specific configuration fields,

    Device conguration layout

    Two configuration fields are currently defined. The mac address field
    always exists (though is only valid if VIRTIO_NET_F_MAC is set), and
    the status field only exists if VIRTIO_NET_F_STATUS is set. [...]

That means, with "status = off" the "status" field should not even be communicated to the guest. That is not the case however:

virtio_config_readb [hw/virtio.c]
  virtio_net_get_config [hw/virtio-net.c] -- via funcptr
    - copies entire "virtio_net_config" structure, including the
      hard-wired "status" field, if the guest asks for it

Side point ends.)

I'm closing this BZ as NOTABUG.

Comment 4 Paolo Bonzini 2012-12-12 14:11:40 UTC
Agree with Laszlo's analysis.  Regarding the "status = off" case, I think the spec's wording is incorrect.  In general, "does not exist" means "is replaced by padding" if the configuration is big enough to include that field.  The host is free to do whatever it wants, the guest however should not trust it.