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

Show IP address of the VM created using inspect json #245

Open
cmoulliard opened this issue Jan 17, 2025 · 5 comments
Open

Show IP address of the VM created using inspect json #245

cmoulliard opened this issue Jan 17, 2025 · 5 comments
Assignees

Comments

@cmoulliard
Copy link

cmoulliard commented Jan 17, 2025

Proposition

It could be very hard for a user to figure out what the IP address of the VM created is when DHCP is used. This is why I would like to propose to use the inspect json response to show it like the hostname of VM

Now

❯ http :60195/vm/inspect
HTTP/1.1 200 OK
Content-Length: 1318
Content-Type: application/json; charset=utf-8
Date: Fri, 17 Jan 2025 10:38:43 GMT

{
    "bootloader": {
        "createVariableStore": true,
        "efiVariableStorePath": "/Users/cmoullia/code/_temp/vfkit/dev/efi-variable-store",
        "kind": "efiBootloader"
    },
    "devices": [
        {
            "devName": "virtio-blk",
            "imagePath": "/Users/cmoullia/code/_temp/vfkit/fedora/Fedora-Cloud-41.raw",
            "kind": "virtioblk"
        },
        {
            "devName": "virtio-blk",
            "imagePath": "/Users/cmoullia/code/_temp/vfkit/fedora/cloudinit.iso",
            "kind": "virtioblk"
        },
        {
            "inputType": "keyboard",
            "kind": "virtioinput"
        },
        {
            "inputType": "pointing",
            "kind": "virtioinput"
        },
        {
            "kind": "virtionet",
            "macAddress": "5a:94:ef:e4:0c:ee",
            "nat": true
        },
        {
            "ignoreIfMissing": false,
            "installRosetta": true,
            "kind": "rosetta",
            "mountTag": "rosetta"
        },
        {
            "kind": "virtiorng"
        },
        {
            "kind": "virtiosock",
            "listen": true,
            "port": 1025,
            "socketURL": "/Users/cmoullia/code/_temp/vfkit/dev/default.sock"
        },
        {
            "kind": "virtioserial",
            "logFile": "/Users/cmoullia/code/_temp/vfkit/dev/default.log"
        },
        {
            "height": 600,
            "kind": "virtiogpu",
            "usesGUI": true,
            "width": 800
        },
        {
            "kind": "virtiofs",
            "mountTag": "user1",
            "sharedDir": "/Users/cmoullia/code/"
        },
        {
            "kind": "virtiosock",
            "listen": true,
            "port": 1024,
            "socketURL": "/var/folders/28/g86pgjxj0wl1nkd_85c2krjw0000gn/T/ignition.sock"
        }
    ],
    "ignition": {
        "configPath": "/Users/cmoullia/code/_temp/vfkit/dev/my-cfg.ign",
        "kind": "ignition",
        "socketPath": "/var/folders/28/g86pgjxj0wl1nkd_85c2krjw0000gn/T/ignition.sock"
    },
    "memoryBytes": 4294967296,
    "vcpus": 2
}

After

{
...
    "memoryBytes": 4294967296,
    "vcpus": 2,
    "vm": {
        "name: "cloud-name",
        "ip": "192.168.64.4"
     }
}
@gbraad
Copy link

gbraad commented Jan 17, 2025

This is related to: #242. As vfkit does not directly interact with the guest OS, it does therefore need to do this from the host.

@evidolob
Copy link

@cfergeau
Copy link
Collaborator

cfergeau commented Jan 22, 2025

https://github.com/crc-org/crc/blob/main/pkg/drivers/vfkit/network_darwin.go has some code parsing the leases file, some of it can probably reused.

EDIT:  posted at the same time as Yevhen's comment ^^

@gbraad
Copy link

gbraad commented Jan 24, 2025

The question I have is; is this really the responsibility of the hypervisor driver. As in this case it is infrastructure and networking. If I had not used DHCP, but bridged, this would not have worked. And I can also not rely on the guest OS, as that might be a different type of OS.

@cfergeau
Copy link
Collaborator

When we have the information, it's worthwhile to provide it instead of telling everyone to go parse a file by themselves in a non obvious location.
It's similar to what we do for timesync or ignition or #208
This can be done without vfkit involvement, but it is still closely tied with the hypervisor, so we add helpers to things easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

4 participants