Skip to content

Conversation

@fatelei
Copy link

@fatelei fatelei commented Dec 17, 2025

fix #125

@fatelei fatelei force-pushed the issue-125 branch 4 times, most recently from 2f0b6dd to d924fb3 Compare December 17, 2025 09:46
@AkihiroSuda
Copy link
Member

qemnu

typo

@fatelei fatelei changed the title feat: add correct qemnu inspect status method feat: add correct qemu inspect status method Dec 17, 2025
@AkihiroSuda
Copy link
Member

The commit message has the typo too

@fatelei
Copy link
Author

fatelei commented Dec 17, 2025

The commit message has the typo too

fixed

@afbjorklund
Copy link
Member

Note that when returning "", the store will check the PID files. So it is the default implementation.

StatusUnknown       Status = ""
        if status == "" {
                inspectStatusWithPIDFiles(instDir, inst, y)
                return
        }

current code:

        var err error
        inst.DriverPID, err = ReadPIDFile(filepath.Join(instDir, filenames.PIDFile(*y.VMType)))
        if err != nil {
                inst.Status = limatype.StatusBroken
                inst.Errors = append(inst.Errors, err)
        }

        if inst.Status == limatype.StatusUnknown {
                switch {
                case inst.HostAgentPID > 0 && inst.DriverPID > 0:
                        inst.Status = limatype.StatusRunning
                case inst.HostAgentPID == 0 && inst.DriverPID == 0:
                        inst.Status = limatype.StatusStopped
                case inst.HostAgentPID > 0 && inst.DriverPID == 0:
                        inst.Errors = append(inst.Errors, errors.New("host agent is running but driver is not"))
                        inst.Status = limatype.StatusBroken
                default:
                        inst.Errors = append(inst.Errors, fmt.Errorf("%s driver is running but host agent is not", inst.VMType))
                        inst.Status = limatype.StatusBroken
                }
        }

this PR:

	qemuPIDPath := filepath.Join(instance.Dir, filenames.PIDFile(limatype.QEMU))
	if _, statErr := os.Stat(qemuPIDPath); statErr != nil {
		if errors.Is(statErr, os.ErrNotExist) {
			return ""
		}
		return limatype.StatusBroken
	}
	pid, err := store.ReadPIDFile(qemuPIDPath)
	if err != nil {
		return limatype.StatusBroken
	}

	if pid == 0 {
		return limatype.StatusBroken
	}

Copy link
Member

@afbjorklund afbjorklund left a comment

Choose a reason for hiding this comment

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

I don't think this is needed, since it does the same as the default/fallback?

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.

limactl ls should verify for "Running" instances that the process is still alive

3 participants