Skip to content

Commit 0aba0a8

Browse files
committed
kvm: Unbreak minikube on Fedora/RHEL
Since #20852 minikube is broken on Fedora/RHEL. We add console.log (~/.minikube/machines/NAME/console.log) for dumping the console logs during startup. Libvirt is blocked by selinux policy: $ sudo ausearch -m AVC --start today ... ---- time->Sat Sep 13 22:14:10 2025 type=AVC msg=audit(1757790850.921:4801): avc: denied { open } for pid=215452 comm="virtlogd" path="/home/nsoffer/.minikube/machines/minikube/console.log" dev="vda3" ino=197349579 scontext=system_u:system_r:virtlogd_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1 ---- Having better logs in the kvm driver can be helpful but it cannot break basic functionality. Remove the code to create the log file and dump the logs. This is a manual revert of commit 2b81ce2. We cannot do a clean revert since all commits in #20852 were squashed during merge. Tested using: $ make out/docker-machine-driver-kvm2 $ cp out/docker-machine-driver-kvm2 ~/.minikube/bin/ $ out/minikube start --driver kvm 😄 minikube v1.37.0 on Fedora 42 (kvm/amd64) ✨ Using the kvm2 driver based on user configuration 👍 Starting "minikube" primary control-plane node in "minikube" cluster 🔥 Creating kvm2 VM (CPUs=2, Memory=6144MB, Disk=20000MB) ... 🐳 Preparing Kubernetes v1.34.0 on Docker 28.4.0 ... 🔗 Configuring bridge CNI (Container Networking Interface) ... 🔎 Verifying Kubernetes components... ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5 🌟 Enabled addons: storage-provisioner, default-storageclass ❗ /usr/local/bin/kubectl is version 1.32.1, which may have incompatibilities with Kubernetes 1.34.0. ▪ Want kubectl v1.34.0? Try 'minikube kubectl -- get pods -A' 🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
1 parent 574f958 commit 0aba0a8

File tree

3 files changed

+1
-54
lines changed

3 files changed

+1
-54
lines changed

pkg/drivers/kvm/domain.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,7 @@ func closeDomain(dom *libvirt.Domain, conn *libvirt.Connect) error {
7070
func (d *Driver) defineDomain() (*libvirt.Domain, error) {
7171
tmpl := template.Must(template.New("domain").Parse(domainTmpl))
7272
var domainXML bytes.Buffer
73-
dlog := struct {
74-
Driver
75-
ConsoleLogPath string
76-
}{
77-
Driver: *d,
78-
ConsoleLogPath: consoleLogPath(*d),
79-
}
80-
if err := tmpl.Execute(&domainXML, dlog); err != nil {
73+
if err := tmpl.Execute(&domainXML, d); err != nil {
8174
return nil, errors.Wrap(err, "executing domain xml")
8275
}
8376
conn, err := getConnection(d.ConnectionURI)

pkg/drivers/kvm/domain_definition_x86.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ const domainTmpl = `
5555
<source file='{{.DiskPath}}'/>
5656
<target dev='hda' bus='virtio'/>
5757
</disk>
58-
<controller type='virtio-serial'/>
5958
<interface type='network'>
6059
<source network='{{.PrivateNetwork}}'/>
6160
<model type='virtio'/>
@@ -66,14 +65,10 @@ const domainTmpl = `
6665
</interface>
6766
<serial type='pty'>
6867
<target port='0'/>
69-
<log file='{{.ConsoleLogPath}}' append='on'/>
7068
</serial>
7169
<console type='pty'>
7270
<target type='serial' port='0'/>
7371
</console>
74-
<console type='pty'>
75-
<target type="virtio" port="1"/>
76-
</console>
7772
<rng model='virtio'>
7873
<backend model='random'>/dev/random</backend>
7974
</rng>

pkg/drivers/kvm/kvm.go

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -314,24 +314,6 @@ func (d *Driver) Start() error {
314314
log.Debugf("starting domain XML:\n%s", domXML)
315315
}
316316

317-
// libvirt/qemu creates a console log file owned by root:root and permissions 0600,
318-
// so we pre-create it (and close it immediately), just to be able to read it later
319-
logPath := consoleLogPath(*d)
320-
f, err := os.Create(logPath)
321-
if err != nil {
322-
log.Debugf("failed to create console log file %q: %v", logPath, err)
323-
} else {
324-
f.Close()
325-
}
326-
// ensure console log file is cleaned up
327-
defer func() {
328-
if _, err := os.Stat(logPath); err == nil {
329-
if err := os.Remove(logPath); err != nil {
330-
log.Debugf("failed removing console log file %q: %v", logPath, err)
331-
}
332-
}
333-
}()
334-
335317
if err := dom.Create(); err != nil {
336318
return errors.Wrap(err, "creating domain")
337319
}
@@ -355,12 +337,6 @@ func (d *Driver) Start() error {
355337
return nil
356338
}
357339

358-
// consoleLogPath returns the path to the console log file for the given machine name.
359-
func consoleLogPath(d Driver) string {
360-
// return fmt.Sprintf("%s-console.log", machineName)
361-
return d.ResolveStorePath("console.log")
362-
}
363-
364340
// waitForDomainState waits maxTime for the domain to reach a target state.
365341
func (d *Driver) waitForDomainState(targetState state.State, maxTime time.Duration) error {
366342
query := func() error {
@@ -377,27 +353,11 @@ func (d *Driver) waitForDomainState(targetState state.State, maxTime time.Durati
377353
return fmt.Errorf("last domain state: %q", currentState.String())
378354
}
379355
if err := retry.Local(query, maxTime); err != nil {
380-
dumpConsoleLogs(consoleLogPath(*d))
381356
return fmt.Errorf("timed out waiting %v for domain to reach %q state: %w", maxTime, targetState.String(), err)
382357
}
383358
return nil
384359
}
385360

386-
// dumpConsoleLogs prints out the console log.
387-
func dumpConsoleLogs(logPath string) {
388-
if _, err := os.Stat(logPath); err != nil {
389-
log.Debugf("failed checking console log file %q: %v", logPath, err)
390-
return
391-
}
392-
393-
data, err := os.ReadFile(logPath)
394-
if err != nil {
395-
log.Debugf("failed dumping console log file %q: %v", logPath, err)
396-
return
397-
}
398-
log.Debugf("console log:\n%s", data)
399-
}
400-
401361
// waitForStaticIP waits for IP address of domain that has been created & starting and then makes that IP static.
402362
func (d *Driver) waitForStaticIP(conn *libvirt.Connect, maxTime time.Duration) error {
403363
query := func() error {
@@ -416,7 +376,6 @@ func (d *Driver) waitForStaticIP(conn *libvirt.Connect, maxTime time.Duration) e
416376
return nil
417377
}
418378
if err := retry.Local(query, maxTime); err != nil {
419-
dumpConsoleLogs(consoleLogPath(*d))
420379
return fmt.Errorf("domain %s didn't return IP after %v", d.MachineName, maxTime)
421380
}
422381

0 commit comments

Comments
 (0)