virt-manager hangs on ‘searching for available hypervisors’ window and not able to cancel it ?

Ah… I would say it ruined my day ūüôā

I updated my fedora system from fedora 18 to 19 as mentioned in my previous post ( website-humblec.rhcloud.com/smooth-upgrade-from-fedora-18-to-fedora-19/ ) and was trying to play with VMs via virt-manager.

How-ever virt-manager showed a window with title ‘Searching for available hypervisors’ and keep showing it indefinitely. I waited for some time and realized its stuck and not going to give me a result.

I knew something is going wrong and decided to fetch it..

How would you troubleshoot ? any way, I had virt-manager upstream repo cloned in my system and realized things are easy when you look at the code.

It was not that tough to find out, its going wrong with the ‘packageKit’ lookup. Knowing only ‘yum’ process can talk to only one, I came to know its the root cause.

To prove it , I tried ‘ps’ command and noticed there is a ‘yum’ process already running .

Ahhhhhhhhh.. Then obviously my next step was to ‘kill this process’..

That did the trick! Once the above process is killed , virt-manager progressed from the ‘problematic’ window.

I had also noticed, when I tried to click on ‘cancel’ button, virt-manager didnt respect it. No effect at all.

So, obviously there is a bug and a possibility of a better user notification.

So, I decided to file a bug and propose patches for both.

Just before filing bug, I did a random search on this behaviour , my luck , I noticed a similar bug report from F-16 time and a recent update on the bugzilla saying some one faced the issue in F-19 as well.

You can read the same report at:

bugzilla.redhat.com/show_bug.cgi?id=746011

Comment 5,6,7 in the above bugzilla made my evening .. :)..

Now, let me wait for Cole to revert on this. At-least for now, you have a work around of killing ‘running yum process’ to progress further..

[update]

Cole is back with valid points and you can track it in bugzilla.redhat.com/show_bug.cgi?id=746011#c9 & c#10

linux system call error codes ( errnos) to human readable error strings..

 

 

Q) ¬† “I got an ‘errno’ returned from the system call and want to map to the exact error message or to the error string which is human readable..

How can I do that ??

This was answered quite few times, how-ever I forgot to share it here, but not this time.

Here is the complete listing of linux error code numbers with its explanation:

 

Why I pasted all these and From where I got it ?

1) ( Why )=> Ans: As a quick reference

2) ( From where) => ‘Errnos’ upto “35” is available in /usr/include/asm-generic/errno-base.h and >35 is available in /usr/include/asm-generic/errno.h

 

How to create a system tap module from a system tap script ?

Yes, simple , Isn’t it ? but it may not be simple for someone who just started with it, so the post

You could try something like below to generate a module

# stap -k -p4 script.stp

  -k     Keep  the  temporary directory after all processing.  This may be useful in order to examine the generated C code, or to reuse the
compiled kernel object.

The temp directory will be called some thing like below in “tmp” fileststem

“/tmp/stapKaKM2c”

-p4 , does “4th level” of pasrsing which end up in module creation..

Also check “-m” option of stap.

Explore “Qemu Tracing ” ..

Qemu provides a new “tracing” mechanism which can be used in conjuction with several backends.. Especially useful to make use of it via “system Tap” which shipped with most of the distros..

 

The trace points are really useful when debugging or when doing performance analysis. The trace events can be enabled/disabled at run time.. For more information on “qemu tracing” and trace events please read below URL.

 

Git repository:

repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/tracing

User documentation

Generate intermediate files ( assembling, preprocessing) in gcc

It is good to see the output files generated by GCC at its each ( preprocessing, assembling..etc) stage.. You will get an idea on  different processes involved and the result worked out by GCC to make a binary/ELF..There are different ways to generate these output files by specifying GCC options..That said, it is possible to generate only assembly output of your source by below way:

#gcc -S -c program.c

Ex:

[root@humbles-lap gcc]# ls
program.c

[root@humbles-lap gcc]# file program.c
program.c: ASCII text
[root@humbles-lap gcc]# gcc -S -c program.c
[root@humbles-lap gcc]# ls
program.c  program.s
[root@humbles-lap gcc]# file program.s
program.s: ASCII assembler program text
[root@humbles-lap gcc]# cat program.s |head -n 5
    .file    "program.c"
    .section    .rodata
    .align 8
.LC0:
    .string    "\n I am always  an example program"
[root@humbles-lap gcc]#How-ever it wont give you all the resulted files in each stage , for ex: preprocessor files. For that, I use below gcc option to generate different output files of my source..#man gcc

       -save-temps
       -save-temps=cwd
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† Store the usual “temporary” intermediate files permanently; place them in the current directory and name them based on
           the source file.  Thus, compiling foo.c with -c -save-temps would produce files foo.i and foo.s, as well as foo.o.
           This creates a preprocessed foo.i output file even though the compiler now normally uses an integrated preprocessor.

           When used in combination with the -x command line option, -save-temps is sensible enough to avoid over writing an input
           source file with the same extension as an intermediate file.  The corresponding intermediate file may be obtained by
           renaming the source file before using -save-temps.

           If you invoke GCC in parallel, compiling several different source files that share a common base name in different
           subdirectories or the same source file compiled for multiple output destinations, it is likely that the different
           parallel compilers will interfere with each other, and overwrite the temporary files.  For instance:

                   gcc -save-temps -o outdir1/foo.o indir1/foo.c&
                   gcc -save-temps -o outdir2/foo.o indir2/foo.c&

           may result in foo.i and foo.o being written to simultaneously by both compilers.

#end of man gcc

As mentioned in “man’ page it will generate “.i”, “s”, “.o” files ..

Ex:

[root@humbles-lap gcc]# ls
program.c
[root@humbles-lap gcc]# gcc -o program program.c --save-temps

[root@humbles-lap gcc]# ls
program  program.c  program.i  program.o  program.s
[root@humbles-lap gcc]# file program.i
program.i: ASCII C program text
[root@humbles-lap gcc]# file program.s
program.s: ASCII assembler program text
[root@humbles-lap gcc]# file program.o
program.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
[root@humbles-lap gcc]# file program
program: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, not stripped
[root@humbles-lap gcc]#Examine those “intermediate files” and try to make sense out of it.. it is funny..I will write more about each stage in another blog..

Who told “malloc” is a system call ?

“The malloc() function allocates size bytes and returns a pointer to the allocated memory. The memory is not initialized. If size is 0, then malloc() returns either NULL, or a unique pointer value that can later be successfully passed to free().”

 

 

Recently I was attending a session and the speaker said in between about “malloc” system call. It made this blog..

 

Ah… Is malloc a system call ? NO.. NO.. NO.. malloc is not a system call.. First of all let me explain what malloc() is.. In simple terms, memory can be assigned either statically or dynamically.. malloc() is a routine which can be used to allocate memory in dynamic way.. But please note that “malloc” is not a system call, it is provided by C library..

 

The memory can be requested at run time via malloc call and this memory is returned on “heap” ( internal?)¬† space. Before getting into the details of malloc() call, let me explain the (s)brk() ( “brk” family)¬† calls.. brk() call can be used to expand/shrink the heap space. More precicely “brk()” call can be used to adjust “data” segment of a program.

malloc() routine make use of brk()¬† calls to do this job. Library calls should give us more performance than the system call.. brk()¬† call is executed with a batch of malloc requests . Now, Is it only “brk()”¬† call is used by malloc routine ? No, there is one more dependent call called “mmap()” . The decision on when to use “brk() and when to use “mmap()”¬† is taken by C library. That said, some of the parameters of C library decide whether it has to go ahead with the “brk()” or “mmap()” way.

 

This is documented in man page of malloc.

 

–snip–

 

Normally, malloc() allocates memory from the heap, and adjusts the size of the heap as required, using sbrk(2). When allocating blocks of memory larger than MMAP_THRESHOLD bytes, the glibc malloc() implementation allocates the memory as a private anonymous mapping using mmap(2). MMAP_THRESHOLD is 128 kB by default, but is adjustable using mallopt(3). Allo‚Äź cations performed using mmap(2) are unaffected by the RLIMIT_DATA resource limit (see getrlimit(2)).

–/snip–

 

I am sure it is pretty much clear from above. As you can see in the man page, “malloc()”, realloc(), “calloc()”, “free()” all lives in the same family.. ūüôā

Now you have to say , Is malloc() a system call ?