Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional Virtual Switch #46

Merged
merged 1 commit into from
Oct 30, 2020
Merged

Conversation

guillaumerose
Copy link

In CRC, VirtualSwitch is always set. When it's empty, we can remove the network interface instead of guessing a name.
https://github.com/code-ready/crc/blob/master/pkg/crc/machine/hyperv/driver_windows.go#L20

return err
}

if d.VirtualSwitch == "" {
if err := cmd("Hyper-V\\Remove-VMNetworkAdapter", "-VMName", d.MachineName); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

@guillaumerose this logic is here just to remove the crc named network adapter in case o there is no virtualswitch provided? Is this virtualswitch present by default?

Copy link
Author

Choose a reason for hiding this comment

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

Hyper-V\New-VM always attach a network adapter. I didn't found an argument to disable it. I had to remove it by hand just after.

Copy link
Member

Choose a reason for hiding this comment

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

Attach a network adapter as name of the machine? @gbraad you have any idea around it?

Copy link

Choose a reason for hiding this comment

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

New-vm might enforce an interface, just not aware this was the case. Will check

Copy link

Choose a reason for hiding this comment

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

there is no way around this

@guillaumerose
Copy link
Author

PR rebased

"-MemoryStartupBytes", toMb(d.Memory),
}
if d.VirtualSwitch != "" {
log.Infof("Creating VM...")
Copy link

Choose a reason for hiding this comment

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

this creating VM message is not part of the switch check.... ?

Copy link
Author

Choose a reason for hiding this comment

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

done

return err
}

if d.VirtualSwitch == "" {
Copy link

Choose a reason for hiding this comment

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

can't this move up and be part of the else clause of:

if d.VirtualSwitch != "" {

Copy link
Author

Choose a reason for hiding this comment

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

VM is created line 229 here in cmd(args...). else is before and too early in the process.

@@ -398,6 +410,10 @@ func (d *Driver) Kill() error {
}

func (d *Driver) GetIP() (string, error) {
Copy link

Choose a reason for hiding this comment

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

over time we could get rid of these functions

Copy link
Author

Choose a reason for hiding this comment

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

yes!

gbraad
gbraad previously requested changes Oct 13, 2020
Copy link

@gbraad gbraad left a comment

Choose a reason for hiding this comment

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

minor issues, related to ordering of code

@guillaumerose
Copy link
Author

Release is done. Merging it.

@guillaumerose guillaumerose removed the request for review from gbraad October 30, 2020 13:55
@guillaumerose guillaumerose merged commit 1ed3c99 into crc-org:master Oct 30, 2020
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.

3 participants