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

internal/server/instance/drivers: Disable 9p and vsock for Windows VMs #1217

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 44 additions & 38 deletions internal/server/instance/drivers/driver_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -3384,25 +3384,28 @@ func (d *qemu) generateQemuConfigFile(cpuInfo *cpuTopology, mountInfo *storagePo

cfg = append(cfg, qemuTablet(&tabletOpts)...)

// Existing vsock ID from volatile.
vsockID, err := d.getVsockID()
if err != nil {
return "", nil, err
}
// Windows doesn't support virtio-vsock.
if !strings.Contains(strings.ToLower(d.expandedConfig["image.os"]), "windows") {
// Existing vsock ID from volatile.
vsockID, err := d.getVsockID()
if err != nil {
return "", nil, err
}

devBus, devAddr, multi = bus.allocate(busFunctionGroupGeneric)
vsockOpts := qemuVsockOpts{
dev: qemuDevOpts{
busName: bus.name,
devBus: devBus,
devAddr: devAddr,
multifunction: multi,
},
vsockFD: vsockFD,
vsockID: vsockID,
}
devBus, devAddr, multi = bus.allocate(busFunctionGroupGeneric)
vsockOpts := qemuVsockOpts{
dev: qemuDevOpts{
busName: bus.name,
devBus: devBus,
devAddr: devAddr,
multifunction: multi,
},
vsockFD: vsockFD,
vsockID: vsockID,
}

cfg = append(cfg, qemuVsock(&vsockOpts)...)
cfg = append(cfg, qemuVsock(&vsockOpts)...)
}

devBus, devAddr, multi = bus.allocate(busFunctionGroupGeneric)
serialOpts := qemuSerialOpts{
Expand Down Expand Up @@ -3450,25 +3453,10 @@ func (d *qemu) generateQemuConfigFile(cpuInfo *cpuTopology, mountInfo *storagePo

cfg = append(cfg, qemuSCSI(&scsiOpts)...)

// Always export the config directory as a 9p config drive, in case the host or VM guest doesn't support
// virtio-fs.
devBus, devAddr, multi = bus.allocate(busFunctionGroup9p)
driveConfig9pOpts := qemuDriveConfigOpts{
dev: qemuDevOpts{
busName: bus.name,
devBus: devBus,
devAddr: devAddr,
multifunction: multi,
},
name: "config",
protocol: "9p",
path: d.configDriveMountPath(),
}

cfg = append(cfg, qemuDriveConfig(&driveConfig9pOpts)...)

// Pass in the agents if INCUS_AGENT_PATH is set.
if util.PathExists(os.Getenv("INCUS_AGENT_PATH")) {
// Windows doesn't support virtio-9p.
if !strings.Contains(strings.ToLower(d.expandedConfig["image.os"]), "windows") {
// Always export the config directory as a 9p config drive, in case the host or VM guest doesn't support
// virtio-fs.
devBus, devAddr, multi = bus.allocate(busFunctionGroup9p)
driveConfig9pOpts := qemuDriveConfigOpts{
dev: qemuDevOpts{
Expand All @@ -3477,12 +3465,30 @@ func (d *qemu) generateQemuConfigFile(cpuInfo *cpuTopology, mountInfo *storagePo
devAddr: devAddr,
multifunction: multi,
},
name: "agent",
name: "config",
protocol: "9p",
path: os.Getenv("INCUS_AGENT_PATH"),
path: d.configDriveMountPath(),
}

cfg = append(cfg, qemuDriveConfig(&driveConfig9pOpts)...)

// Pass in the agents if INCUS_AGENT_PATH is set.
if util.PathExists(os.Getenv("INCUS_AGENT_PATH")) {
devBus, devAddr, multi = bus.allocate(busFunctionGroup9p)
driveConfig9pOpts := qemuDriveConfigOpts{
dev: qemuDevOpts{
busName: bus.name,
devBus: devBus,
devAddr: devAddr,
multifunction: multi,
},
name: "agent",
protocol: "9p",
path: os.Getenv("INCUS_AGENT_PATH"),
}

cfg = append(cfg, qemuDriveConfig(&driveConfig9pOpts)...)
}
}

// If user has requested AMD SEV, check if supported and add to QEMU config.
Expand Down
Loading