File: source_qemu.py

package info (click to toggle)
qemu 1%3A5.2%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 201,372 kB
  • sloc: ansic: 2,327,506; pascal: 107,506; asm: 49,545; python: 40,498; sh: 35,286; cpp: 33,587; makefile: 15,209; perl: 6,965; xml: 3,028; objc: 1,460; php: 1,299; tcl: 1,070; yacc: 604; lex: 363; sql: 71; awk: 35; sed: 11
file content (25 lines) | stat: -rw-r--r-- 910 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'''apport package hook for qemu

(c) 2009 Canonical Ltd.
'''

from apport.hookutils import *
import subprocess

def cmd_pipe(command1, command2, input = None, stderr = subprocess.STDOUT, stdin = None):
    '''Try to pipe command1 into command2.'''
    try:
        sp1 = subprocess.Popen(command1, stdin=stdin, stdout=subprocess.PIPE, stderr=stderr, close_fds=True)
        sp2 = subprocess.Popen(command2, stdin=sp1.stdout, stdout=subprocess.PIPE, stderr=stderr, close_fds=True)
    except OSError as e:
        return [127, str(e)]

    out = sp2.communicate(input)[0]
    return [sp2.returncode,out]

def add_info(report):
    attach_hardware(report)
    attach_related_packages(report, ['kvm*', '*libvirt*', 'virt-manager', 'qemu*'])
    rc,output = cmd_pipe(['ps', '-eo', 'comm,stat,euid,ruid,pid,ppid,pcpu,args'], ['egrep', '(^COMMAND|^qemu|^kvm)'])
    if rc == 0:
        report['KvmCmdLine'] = output