VirtualBox

Changeset 88039 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Mar 9, 2021 12:28:53 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
143170
Message:

VBoxManage/modifyvm: Don't try to always helpfully enable a NIC when
changing its attachment, only do that if it's not already enabled.

For a VM in a saved state the attachment can be changed, but the NIC
status cannot, so it was impossible to change NIC attachments from the
command line in that case. Of course, the setter also should not
freak out about a no-op request to enable an already enabled NIC and
that should be fixed, but better be twice shy...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp

    r87241 r88039  
    16331633                ASSERT(nic);
    16341634
     1635                /*
     1636                 * Check if the NIC is already enabled.  Do not try to
     1637                 * enable it if it already is.  That makes a
     1638                 * difference for saved VMs for which you can change
     1639                 * the NIC attachment, but can't change the NIC
     1640                 * enabled status (yes, the setter also should not
     1641                 * freak out about a no-op request).
     1642                 */
     1643                BOOL fEnabled;;
     1644                CHECK_ERROR(nic, COMGETTER(Enabled)(&fEnabled));
     1645
    16351646                if (!RTStrICmp(ValueUnion.psz, "none"))
    16361647                {
    1637                     CHECK_ERROR(nic, COMSETTER(Enabled)(FALSE));
     1648                    if (!!fEnabled)
     1649                        CHECK_ERROR(nic, COMSETTER(Enabled)(FALSE));
    16381650                }
    16391651                else if (!RTStrICmp(ValueUnion.psz, "null"))
    16401652                {
    1641                     CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
     1653                    if (!fEnabled)
     1654                        CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
    16421655                    CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_Null));
    16431656                }
    16441657                else if (!RTStrICmp(ValueUnion.psz, "nat"))
    16451658                {
    1646                     CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
     1659                    if (!fEnabled)
     1660                        CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
    16471661                    CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_NAT));
    16481662                }
     
    16501664                        || !RTStrICmp(ValueUnion.psz, "hostif")) /* backward compatibility */
    16511665                {
    1652                     CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
     1666                    if (!fEnabled)
     1667                        CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
    16531668                    CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_Bridged));
    16541669                }
    16551670                else if (!RTStrICmp(ValueUnion.psz, "intnet"))
    16561671                {
    1657                     CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
     1672                    if (!fEnabled)
     1673                        CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
    16581674                    CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_Internal));
    16591675                }
    16601676                else if (!RTStrICmp(ValueUnion.psz, "hostonly"))
    16611677                {
    1662 
    1663                     CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
     1678                    if (!fEnabled)
     1679                        CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
    16641680                    CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_HostOnly));
    16651681                }
    16661682                else if (!RTStrICmp(ValueUnion.psz, "generic"))
    16671683                {
    1668 
    1669                     CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
     1684                    if (!fEnabled)
     1685                        CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
    16701686                    CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_Generic));
    16711687                }
    16721688                else if (!RTStrICmp(ValueUnion.psz, "natnetwork"))
    16731689                {
    1674 
    1675                     CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
     1690                    if (!fEnabled)
     1691                        CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
    16761692                    CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_NATNetwork));
    16771693                }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette